Anyone experience this before? I have a very simple form, and when I try to submit the form I get an "unknown attribute: commit" error. Here is the form: <% form_for @nominator do |f| %> <%= f.error_messages %> <%= f.label :first_name %> <%= f.text_field :first_name %> <%= f.label :last_name %> <%= f.text_field :last_name %> <%= f.label :email %> <%= f.text_field :email %> <%= f.submit "Register" %> <% end %> And parameters fed: Parameters: {"commit"=>"Register", "nominator"=>{"last_name"=>"Smith", "first_name"=>"Barney", "email"=>"nominator-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org"}} Here''s my model in nominator.rb: class Nominator < ActiveRecord::Base acts_as_authentic has_many :students validates_presence_of :email end Btw, I''m using authlogic, although I don''t suspect that has anything to do with this error, as I''ve commented out the "acts_as_authentic" and still get the same error. Thanks in advance, folks. -Sal -- 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.
On Dec 18, 2009, at 3:45 PM, salamander wrote:> Anyone experience this before? > > I have a very simple form, and when I try to submit the form I get an > "unknown attribute: commit" error. > > Here is the form: > > <% form_for @nominator do |f| %> > <%= f.error_messages %> > > <%= f.label :first_name %> > <%= f.text_field :first_name %> > <%= f.label :last_name %> > <%= f.text_field :last_name %> > <%= f.label :email %> > <%= f.text_field :email %> > <%= f.submit "Register" %>Get rid of f.submit and use submit_tag. That will keep the ''commit'' parameter from being included in params[:nominator].> <% end %> > > > And parameters fed: > > Parameters: > {"commit"=>"Register", > "nominator"=>{"last_name"=>"Smith", > "first_name"=>"Barney", > "email"=>"nominator-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org"}} > > > Here''s my model in nominator.rb: > > class Nominator < ActiveRecord::Base > acts_as_authentic > has_many :students > > validates_presence_of :email > end > > > Btw, I''m using authlogic, although I don''t suspect that has anything > to do with this error, as I''ve commented out the "acts_as_authentic" > and still get the same error. Thanks in advance, folks. > > > -Sal > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . > >-- 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.
On Fri, Dec 18, 2009 at 6:45 PM, salamander <broohaha-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Anyone experience this before? > > I have a very simple form, and when I try to submit the form I get an > "unknown attribute: commit" error. > > Here is the form: > > <% form_for @nominator do |f| %> > <%= f.error_messages %> > > <%= f.label :first_name %> > <%= f.text_field :first_name %> > <%= f.label :last_name %> > <%= f.text_field :last_name %> > <%= f.label :email %> > <%= f.text_field :email %> > <%= f.submit "Register" %> > <% end %> > > > And parameters fed: > > Parameters: > {"commit"=>"Register", > "nominator"=>{"last_name"=>"Smith", > "first_name"=>"Barney", > "email"=>"nominator-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org"}} > > > Here''s my model in nominator.rb: > > class Nominator < ActiveRecord::Base > acts_as_authentic > has_many :students > > validates_presence_of :email > end > > > Btw, I''m using authlogic, although I don''t suspect that has anything > to do with this error, as I''ve commented out the "acts_as_authentic" > and still get the same error. Thanks in advance, folks.Well you don''t show your controller code, which I suspect is the culprit. For example I suspect that you are doing something like Nominator.create(params) or @nominator.update_attributes(params) instead of Nominator.create(params[''nominator'']) or @nominator.update_attributes(params[''nominator'']) or the like in your create and or update actions. Note those parameters {"commit"=>"Register", "nominator"=>{ "last_name"=>"Smith", "first_name"=>"Barney", "email"=>"nominator-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org" } } Not all of the parameters are model attributes. The commit parameter is telling you which button was pushed. It''s usually ignored since there is only one, but ... -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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.
Rick, You hit the nail right on the head! In my controller, I had the following: @nominator = Nominator.new(params) When I changed it to @nominator = Nominator.new(params[''nominator'']) that cleared it up! Thanks! -Sal On Dec 18, 7:43 pm, Rick DeNatale <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Dec 18, 2009 at 6:45 PM, salamander <brooh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Anyone experience this before? > > > I have a very simple form, and when I try to submit the form I get an > > "unknown attribute: commit" error. > > > Here is the form: > > > <% form_for @nominator do |f| %> > > <%= f.error_messages %> > > > <%= f.label :first_name %> > > <%= f.text_field :first_name %> > > <%= f.label :last_name %> > > <%= f.text_field :last_name %> > > <%= f.label :email %> > > <%= f.text_field :email %> > > <%= f.submit "Register" %> > > <% end %> > > > And parameters fed: > > > Parameters: > > {"commit"=>"Register", > > "nominator"=>{"last_name"=>"Smith", > > "first_name"=>"Barney", > > "email"=>"nomina...-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org"}} > > > Here''s my model in nominator.rb: > > > class Nominator < ActiveRecord::Base > > acts_as_authentic > > has_many :students > > > validates_presence_of :email > > end > > > Btw, I''m using authlogic, although I don''t suspect that has anything > > to do with this error, as I''ve commented out the "acts_as_authentic" > > and still get the same error. Thanks in advance, folks. > > Well you don''t show your controller code, which I suspect is the culprit. > > For example I suspect that you are doing something like > > Nominator.create(params) > or > @nominator.update_attributes(params) > > instead of > Nominator.create(params[''nominator'']) > or > @nominator.update_attributes(params[''nominator'']) > > or the like in your create and or update actions. > > Note those parameters > > {"commit"=>"Register", > "nominator"=>{ > "last_name"=>"Smith", > "first_name"=>"Barney", > "email"=>"nomina...-zuv13RyHHZkAvxtiuMwx3w@public.gmane.org" > } > > } > > Not all of the parameters are model attributes. The commit parameter > is telling you which button was pushed. It''s usually ignored since > there is only one, but ... > -- > Rick DeNatale > > Blog:http://talklikeaduck.denhaven2.com/ > Twitter:http://twitter.com/RickDeNatale > WWR:http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn:http://www.linkedin.com/in/rickdenatale-- 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.