http://guides.rubyonrails.org/activerecord_validations_callbacks.html

Start with this to get yourself familiar with how validation_callbacks 
work.  Generally, if you are using a form in a view (form_for as an 
example) you have a form that is backed by the model.  Therefore, you 
are placing the validation checks in the model, not the controller.

Viewer
-- has form_for...
Controller
--
Model
-- validates_presence_of  :name
-- validates_..._ .. etc

Depending on the type of validation you provide in the model, rails will 
automatically catch the error if it occurs.

Keep in mind that if you are using form_tag you cannot perform model 
validation callbacks because that form is not backed by a model.  You'd 
have to use javascript, or something else to do validation checks.




-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to