Ruby on Rails Monday, August 29, 2011

I now have <%= User.new.errors.full_messages %> in my view and this

extend ActiveModel::Naming

def after_initialize
@errors = ActiveModel::Errors.new(self)
end

attr_accessor :login
attr_reader :errors

def validate!
errors.add(:login, "can not be nil") if login == nil
end

def read_attribute_for_validation(attr)
send(attr)
end

def User.human_attribute_login(attr, options = {})
attr
end

def User.lookup_ancestors
[self]
end

In my model

It doesn't throw up any errors but neither does it work.

Where am I going wrong now?

--
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