Hi, i have a validates_something_of_something method in my User model...i added a :message => "you need to abcd" to the validation method, but when i try to access it through the <%= error_messages_for "user" %> it doesn''t give me any output... i was wondering whether there was a way to access all of the (:message => string) methods that are collected from the validation methods in the model; even building my own error helper or something (from the validates_abc, :message => string) to shape it to my own liking...where do i start from ? ? many thanks... -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2006-Sep-12 14:39 UTC
Re: accessing validates_... , :message => ''something''
I do believe your supposed to pass in the i-var, not a string or symbol: <%= error_messages_for @user %> You can also loop through the error messages yourself this way: @user.errors.each_full_messages do |message| stuff; end Jason On 9/12/06, question <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi, > > i have a validates_something_of_something method in my User model...i > added a :message => "you need to abcd" to the validation method, but > when i try to access it through the <%= error_messages_for "user" %> it > doesn''t give me any output... > > i was wondering whether there was a way to access all of the (:message > => string) methods that are collected from the validation methods in the > model; even building my own error helper or something (from the > validates_abc, :message => string) to shape it to my own liking...where > do i start from ? > > ? > > many thanks... > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Michael Campbell
2006-Sep-12 14:52 UTC
Re: accessing validates_... , :message => ''something''
On 9/12/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I do believe your supposed to pass in the i-var, not a string or symbol:String. At least the source handles strings; maybe symbols too, I''m a bit fuzzy on that. Note line 105. # File vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb, line 103 103: def error_messages_for(object_name, options = {}) 104: options = options.symbolize_keys 105: object = instance_variable_get("@#{object_name}") -- Imagination is more important than knowledge. -- Albert Einstein --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---