Hi! Im validating name field in "dev" model by checking its uniqueness. but while editing that particular entry, the system again validates for uniqueness of name. so if i dnt change name while editing , it gives me error: name has already been taken. my update code is : 1. def updateDevice 2. @device=Dev.find(params[:id]) 3. 4. @devtype=Devtype.find_by_id(params[:device][:devtype_id]) 5. 6. if request.post? 7. 8. @device.update_attributes!(params[:device]) 9. redirect_to :action=>"showDevices_admin" 10. end 11. 12. end what is the problem exactly?? Thanx in advance! sups -- View this message in context: http://www.nabble.com/validating_uniqueness_of-creating-problem-while-updating-tp18231473p18231473.html Sent from the RubyOnRails Users mailing list archive at Nabble.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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2008-Jul-02 07:14 UTC
Re: validating_uniqueness_of creating problem while updating
Try validates_uniqueness_of :name, :on => :create --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---