Ruby on Rails Monday, August 29, 2011

Neil Bye wrote in post #1019016:
> 7stud -- wrote in post #1018959:
>
> There are no partials involved I
>
>> @user is an ActiveRecord::Base object, so
>> the errors() method must be defined in that class or one of that class's
>> parent classes (or in a module that one of those classes includes).
>
> Ok I gather that to use 'u.errors.full_messages I need
>
> def initialize
> @errors = ActiveModel::Errors.new(self)
> end
>
> in user.rb
>
> From http://api.rubyonrails.org/classes/ActiveModel/Errors.html
>

No. errors() works automatically in rails3. According to the docs,
errors() returns an object of class ActiveModel::Errors:

http://ar.rubyonrails.org/classes/ActiveRecord/Errors.html

I think the docs you looked at tell you how to provide your model with
an OrderedHash that contains the errors.

I don't know if this could be causing your lack of errors:

validates_presence_of :email


In rails 3 that is written like this:

validates :email, :presence => true

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment