class Place < ActiveRecord::Base validates :description, :presence => true validates :description, :uniqueness => {:case_sensitive => true, :on => :create } # also tried # validates :description, :uniqueness => {:case_sensitive => true }, :on => :create On update ( in form fields, updated label, same description ) params {"event"=>{"place_attributes"=>{"label"=>"a very beautiful place", "description"=>"where you should go..."}} @event.errors debugging @messages={:"place.description"=>["has already been taken"]}> !! uniqueness should not be checked ¿ thanks for any clue .. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/sPAv0OrO8zkJ. For more options, visit https://groups.google.com/groups/opt_out.
On 4 December 2012 10:03, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote:> > class Place < ActiveRecord::Base > > validates :description, :presence => true > validates :description, :uniqueness => {:case_sensitive => true, :on => > :create } > # also tried > # validates :description, :uniqueness => {:case_sensitive => true }, :on > => :create > > On update ( in form fields, updated label, same description ) > params > {"event"=>{"place_attributes"=>{"label"=>"a very beautiful place", > "description"=>"where you should go..."}} > > @event.errors debugging > @messages={:"place.description"=>["has already been taken"]}> !! > uniqueness should not be checked ¿I don''t understand what is happening that is not as you expect. Please try and explain in more detail. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
the[SOLVED] I thought uniqueness of :description was checked on record update even with :on => :create condition for validate... it was , but my functional test was not an update ... I was using post :update, :locale => I18n.locale, :id => @event_0[:id] it MUST be put :update, :locale => I18n.locale, :id => @event_0[:id] Le mardi 4 décembre 2012 11:12:00 UTC+1, Colin Law a écrit :> > On 4 December 2012 10:03, Erwin <yves_...-ee4meeAH724@public.gmane.org <javascript:>> wrote: > > > > class Place < ActiveRecord::Base > > > > validates :description, :presence => true > > validates :description, :uniqueness => {:case_sensitive => true, :on > => > > :create } > > # also tried > > # validates :description, :uniqueness => {:case_sensitive => true }, > :on > > => :create > > > > On update ( in form fields, updated label, same description ) > > params > > {"event"=>{"place_attributes"=>{"label"=>"a very beautiful place", > > "description"=>"where you should go..."}} > > > > @event.errors debugging > > @messages={:"place.description"=>["has already been taken"]}> !! > > uniqueness should not be checked ¿ > > I don''t understand what is happening that is not as you expect. > Please try and explain in more detail. > > Colin >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/7dWPE7w6O9kJ. For more options, visit https://groups.google.com/groups/opt_out.
Apparently Analagous Threads
- case insensitive inclusion validation
- Dynamic find_by method returning nil in a class method
- [Rails 3.2] form_tag w :remote => true doesn't fire up the js format
- Why can I do a case insensitive Validation but not Find?
- [PATCH] v2v: rhv plugin - case-sensitive search queries