Hi,
Is there a way of validating input inside the controller? or an
equivalent to
ActiveRecord::Validations::ClassMethods.validates_presence_of ?
Cheers,
– Colin
Hi,
Is there a way of validating input inside the controller? or an
equivalent to
ActiveRecord::Validations::ClassMethods.validates_presence_of ?
Cheers,
– Colin
just override the validate method
class Foo < ActiveRecord::Base
def validate
errors.add(:name, “is blank”) if name.nil? or name == “”
# other validations
end
end
then you can call @user.valid? at any time
http://rails.rubyonrails.com/classes/ActiveRecord/Validations.html
On 12/19/05, Chris H. [email protected] wrote:
On 12/19/05, Colin JN Breame <[email protected] > wrote:
Hi,
Is there a way of validating input inside the controller? or an equivalent
toActiveRecord::Validations::ClassMethods.validates_presence_of
I have a Rails Weenie tip for validating non-model data. It basically
creates a table-less model you can use for a form:
http://rails.techno-weenie.net/tip/2005/11/19/validate_your_forms_with_a_table_less_model
–
rick
http://techno-weenie.net
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs