eiji
March 12th, 2006, 07:46 AM
hi there.
uhh.. i have this "validates_presence_of" and some other validations (seen below) and i have these message right after.. but how do i print them out once they occur? the validations are being catched nad the view is showing a box-highlight on the textbox that had a validation process but how do i print out the message?
/model/ - validation occurs here
class Memberaccount < ActiveRecord::Base
#database reletionship
belongs_to :user
has_many :accesspoints
#validation
validates_uniqueness_of :username, :message => "username already exists"
validates_format_of :username, :with => /^\w+$/, :message => "cannot contain whitespace"
validates_presence_of :username, :password, :firstname, :lastname, :email, :message => "Missing required field"
end
/view/ - how do i print out the messages?
<h1>SignUp Form</h1>
<form method="post" action="/signup/save">
<table width="200" border="0">
<tr>
<td><label class="required" for="memberaccount_username">*Username: </label></td>
<td><%= text_field 'memberaccount', 'username' %></td>
</tr>
<tr>
<td>*Password: </td>
<td><%= password_field 'memberaccount', 'password' %></td>
</tr>
the view is just a portion because it only repeats itself but on different fields.
thanks for the help :D
uhh.. i have this "validates_presence_of" and some other validations (seen below) and i have these message right after.. but how do i print them out once they occur? the validations are being catched nad the view is showing a box-highlight on the textbox that had a validation process but how do i print out the message?
/model/ - validation occurs here
class Memberaccount < ActiveRecord::Base
#database reletionship
belongs_to :user
has_many :accesspoints
#validation
validates_uniqueness_of :username, :message => "username already exists"
validates_format_of :username, :with => /^\w+$/, :message => "cannot contain whitespace"
validates_presence_of :username, :password, :firstname, :lastname, :email, :message => "Missing required field"
end
/view/ - how do i print out the messages?
<h1>SignUp Form</h1>
<form method="post" action="/signup/save">
<table width="200" border="0">
<tr>
<td><label class="required" for="memberaccount_username">*Username: </label></td>
<td><%= text_field 'memberaccount', 'username' %></td>
</tr>
<tr>
<td>*Password: </td>
<td><%= password_field 'memberaccount', 'password' %></td>
</tr>
the view is just a portion because it only repeats itself but on different fields.
thanks for the help :D