I''m getting this error due to a change necessary for my form. Initially - I was using formhelper where the form_for looked like this: <%= form_tag :action => ''create_position'' %> Now I''ve switched to the scaffold_resource in edge rails where the forms are setup as such: <% form_for(:position, :url => positions_path) do |f| %> So I know that this form_for will also accept the regular formhelpers. However Im running into a problem with a field, where if i don''t add the f (i.e. f.select) the page loads fine but the input is never put into the database. If I put the f on it generates the undefined method merge error. Here is the field: <%= f.select ''pay'', ''id'', Pay.find(:all).collect {|p| [p.name, p.id]}%> Hoping someone can help. TIA Stuart -- http://en.wikipedia.org/wiki/Dark_ambient --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I know this is old news for you but thank you! I''ve been having the same problem and the solution only occurred to me when I read your post. I''m new to Rails, so i''ve been assuming that i''ve been passing incorrect parameters to the select function. For a reason that''s beyond me, the select helper methods fail if you invoke them using the form object. Drop the "f." prefix. The select box is associated with the form via it''s first parameter. You should pass the same instance variable used in your "form_for" declaration. This will work: <% form_for(@user) do |f| %> __<p> ____<%= f.label "Admin" %><br /> ____<%= select :user, :admin, [ ["True",1], ["False",0]] %> __</p> __<p> ____<%= f.submit "Create" %> __</p> <% end %> This creates a select box that sets the ''user'' objects ''admin'' attribute to 1 or 0. The first parameter must match the ''form_for'' instance variable or they will not be associated with any lines like this; @user = User.new(params[:user]) I hope that''s clear for anyone having the same nightmare. I found this page especially useful on select boxes; http://shiningthrough.co.uk/blog/show/6 Stuart Fellowes wrote: (back in 2006 lol)> I''m getting this error due to a change necessary for my form. > > Initially - I was using formhelper where the form_for looked like this: > <%= form_tag :action => ''create_position'' %> > > Now I''ve switched to the scaffold_resource in edge rails where the > forms are setup as such: > <% form_for(:position, :url => positions_path) do |f| %> > > So I know that this form_for will also accept the regular formhelpers. > However Im running into a problem with a field, where if i don''t add > the f (i.e. f.select) the page loads fine but the input is never put > into the database. > If I put the f on it generates the undefined method merge error. > Here is the field: > > <%= f.select ''pay'', ''id'', Pay.find(:all).collect {|p| [p.name, p.id]}%> > > Hoping someone can help. > TIA > Stuart >-- 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 -~----------~----~----~----~------~----~------~--~---
Dean - thank you! Dropping the f. was something I hadn''t even considered - just got my app working again (though the select list is not showing up but at least it''s progress...). Dean Close wrote:> I know this is old news for you but thank you! I''ve been having the > same problem and the solution only occurred to me when I read your post. > I''m new to Rails, so i''ve been assuming that i''ve been passing incorrect > parameters to the select function. > > For a reason that''s beyond me, the select helper methods fail if you > invoke them using the form object. Drop the "f." prefix. The select > box is associated with the form via it''s first parameter. You should > pass the same instance variable used in your "form_for" declaration. >-- 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 -~----------~----~----~----~------~----~------~--~---