Hi, I can validate and pop up error messages using, validates_presence_of :txt_field .But how do I change the error message from this: 1 error prohibited this abc form from being saved There were problems with the following fields: * Txt field can''t be blank Into this: 1 error prohibited this abc form from being saved There were problems with the following fields: * Text field can''t be blank Can anyone help me resolve this? 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?hl=en -~----------~----~----~----~------~----~------~--~---
Correctly name your fields in the first place? On Jan 21, 2008 1:50 PM, user splash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > I can validate and pop up error messages using, validates_presence_of > :txt_field .But how do I change the error message from this: > > 1 error prohibited this abc form from being saved > > There were problems with the following fields: > > * Txt field can''t be blank > > > > Into this: > > 1 error prohibited this abc form from being saved > > There were problems with the following fields: > > * Text field can''t be blank > > > Can anyone help me resolve this? Thanks > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Correctly name your fields in the first place? > > > On Jan 21, 2008 1:50 PM, user splash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > >> * Txt field can''t be blank >> >> >> Can anyone help me resolve this? Thanks >> --Hi, Can I change without correcting my field names? 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?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, whether you have to change your error message content or the field name.. 1. you can change the name of the text field as text_field (or) 2. you can add the message like validates_presence_of :text_field,:message=>"Text field can''t be empty" Regards Abirami.s -- 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 :text_field,:message=>"Text field > can''t be empty" >I thought that would display it as "txt field Text field can''t be empty" -- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:>> >> >> validates_presence_of :text_field,:message=>"Text field >> can''t be empty" >> > > I thought that would display it as "txt field Text field can''t be empty" > > --Hi, I''ve tried the suggestion, validates_presence_of :text_field,:message=>"Text field can''t be empty", posted by Abirami Selvam (abirami). The results are just as Ryan Bigg posted. "Txt field Text field can''t be empty" -- 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 -~----------~----~----~----~------~----~------~--~---
user splash wrote:> Ryan Bigg wrote: >>> >>> validates_presence_of :text_field,:message=>"Text field >>> can''t be empty" >>> >> I thought that would display it as "txt field Text field can''t be empty" >> >> -- > > > > Hi, > > I''ve tried the suggestion, validates_presence_of > :text_field,:message=>"Text field can''t be empty", posted by Abirami > Selvam (abirami). The results are just as Ryan Bigg posted. "Txt field > Text field can''t be empty" >You can use a custom validation method: def validate errors.add_to_base("Text field can''t be empty") if txt_field.blank? end or you could perhaps use a virtual field call text_field and translate between the two, but all this seems well overcomplicated compared to just renaming the field! Cheers, Gary. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try Something like this: (this one is for testing the uniqueness of a ''name'' field, but can be adapted to whatever...) before_validation_on_create ''self.class.validates_uniqueness_of :name, :message=>"You can use #{self.name}, it''s gone!!!!"'' -- 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 -~----------~----~----~----~------~----~------~--~---
Correctly name your fields in the first place? rubbish. In my case I just need error messages in a different language (geman). I can''t name database columns using german words (at least not in all cases like with umlauts). I add :message=>"Text field can''t be empty" to my validation and then display errors like this: @object.errors.each do |field,message| # display message only end _jan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 1, 11:08 am, Mr Horse <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> before_validation_on_create ''self.class.validates_uniqueness_of :name, > :message=>"You can use #{self.name}, it''s gone!!!!"''It really sucks that we have to resort to hacks for stuff like this. This is begging for a patch or plugin... -- Justin Blake http://mega.blaix.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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You mean begging someone _else_ to make a patch or plugin, right? RSL On Feb 4, 2008 10:46 AM, Justin Blake <jblaix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Feb 1, 11:08 am, Mr Horse <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > before_validation_on_create ''self.class.validates_uniqueness_of :name, > > :message=>"You can use #{self.name}, it''s gone!!!!"'' > > It really sucks that we have to resort to hacks for stuff like this. > This is begging for a patch or plugin... > > -- > Justin Blake > http://mega.blaix.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 -~----------~----~----~----~------~----~------~--~---