[Rails 3.2.1, Ruby 1.9.3] in a Project model I am trying to modify the :location attribute validation ( specific LocationValidator using Geocoder..) I need now to set it on create only so I wrote : validates :location, :location => { :on => :create } but when I update the project instance, I get an error : project.update_attributes(specific_payment: partner[:specific_payment]) => false project.errors => #<ActiveModel::Errors:... @messages={:location=>["?"] if I add the location attribute in the update , then it works ... location = project.geocode[:address] project.update_attributes(specific_payment: partner[:specific_payment], location: location) => true so, { :on => :create } seems not to be working .. what could be wrong ? thanks for your feedback -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
FORGET ... SOLVED I found a validates :name, :subject, :location, :description, :presence => true few lines above .... ! so the presence validation should be updated too.... On 23 fév, 12:26, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote:> [Rails 3.2.1, Ruby 1.9.3] > > in a Project model > I am trying to modify the :location attribute validation ( specific > LocationValidator using Geocoder..) > I need now to set it on create only > > so I wrote : > validates :location, :location => { :on => :create } > > but when I update the project instance, I get an error : > > project.update_attributes(specific_payment: > partner[:specific_payment]) > => false > > project.errors > => #<ActiveModel::Errors:... > @messages={:location=>["?"] > > if I add the location attribute in the update , then it works ... > location = project.geocode[:address] > project.update_attributes(specific_payment: > partner[:specific_payment], location: location) > => true > > so, { :on => :create } seems not to be working .. what could be > wrong ? > > thanks for your feedback-- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> so I wrote : > validates :location, :location => { :on => :create } >why don''t you write: validates :location, :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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.