suppose i have a model: class Foo belongs_to :some_customized_bar validates_presence_of :some_customized_bar_id end if i use ''error_messages_for :foo'' in a view, i''ll get errors like: "Some customized bar can''t be blank" is it possible to tell the validator to use another name for that field, or do i have to do it myself using the model.errors collection? thanks, jeff --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Jeff Emminger wrote:> suppose i have a model: > > class Foo > belongs_to :some_customized_bar > validates_presence_of :some_customized_bar_id > end > > > if i use ''error_messages_for :foo'' in a view, i''ll get errors like: > "Some customized bar can''t be blank" > > is it possible to tell the validator to use another name for that > field, or do i have to do it myself using the model.errors collection? > > thanks, > jeffvalidates_presence_of :some_customized_bar_id, :message => "RubyonRails is Awesome" -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
> validates_presence_of :some_customized_bar_id, :message => "RubyonRails > is Awesome"Jamal -- I''m not sure this answered Jeff''s question, which involved setting another name for the *field*, I believe. Adding the :message parameter only affects what''s after the field name, so when a form is validated, the <%= error_messages_for ''widget'' %> results in text like "Some customized bar RubyonRails is Awesome" Is there a way to also change the field name (or not have it show up at all?) Thanks Jamal, and thanks Jeff for asking the question :-) Tom --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---