Is there a way to remove a specific error or errors on a specific attribute? I see there is a object.errors.clear, but that clears all the errors associated with the object. I would like to do something like object.errors.clear(''email''), where any errors associated with the email attribute are cleared out. Thanks, 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 -~----------~----~----~----~------~----~------~--~---
alexander-0M91wEDH++c@public.gmane.org
2007-May-18 20:01 UTC
Re: Removing Specific ActiveRecord Errors
dear sender, i´m out of the office until may 29th. your email will not be forwarded. for urgent stuff please contact joern-0M91wEDH++c@public.gmane.org kind regards, alexander --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom, did you ever get a solution to this problem, or even a work around. I''ve got the same issue now. Thanks in Advance Tom Styles TomRossi7 wrote:> Is there a way to remove a specific error or errors on a specific > attribute? I see there is a object.errors.clear, but that clears all > the errors associated with the object. I would like to do something > like object.errors.clear(''email''), where any errors associated with > the email attribute are cleared out.-- 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 -~----------~----~----~----~------~----~------~--~---
object.errors looks like a hash. Can you do a puts object.errors and post the result? If it says :email => ''foo'' somewhere, you should be able to do object.errors.clear :email On Fri, Sep 19, 2008 at 1:54 PM, Tom Styles < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Tom, did you ever get a solution to this problem, or even a work around. > I''ve got the same issue now. > > Thanks in Advance > Tom Styles > > TomRossi7 wrote: > > Is there a way to remove a specific error or errors on a specific > > attribute? I see there is a object.errors.clear, but that clears all > > the errors associated with the object. I would like to do something > > like object.errors.clear(''email''), where any errors associated with > > the email attribute are cleared out. > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the tip Commander. I figured it out. I was needing to do a validates_associated but I didn''t want the error message to appear in my view. My answer to this at the time was to remove the error message once the object had been validated. However a much better way was to write my own validate statement def validate return false unless self.associated_object.valid? end This way I''m checking that the associated object is valid without generating the errors in the first place. I love the rails validates helpers so much that I forget I can do validation myself and get all the control I''ll ever need. Cheers Tom -- 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 -~----------~----~----~----~------~----~------~--~---
Tom Styles wrote:> I was needing to do a validates_associated but I didn''t want the error > message to appear in my view. My answer to this at the time was to > remove the error message once the object had been validated. > > However a much better way was to write my own validate statement > > def validate > return false unless self.associated_object.valid? > end > > This way I''m checking that the associated object is valid without > generating the errors in the first place. > > I love the rails validates helpers so much that I forget I can do > validation myself and get all the control I''ll ever need.You can also use :message => nil option on the validates_associated statement. -- Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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 -~----------~----~----~----~------~----~------~--~---