Hello, I would like to have a link_to automatically populate a field in the form that it is linking to. For example (excuse my silly words, im trying to make a point) <%= link_to "Add a COOL Post", new_post_path, :howcoolisit => ''COOL'' %> <%= link_to "Add a NOTCOOL Post", new_post_path, :howcoolisit => ''NOTCOOL'' %> Then, I would have a field in that form: <%= f.hidden_field :howcoolisit %> And I would want it to be populated automatically (either NOTCOOL, or COOL, depending on the link_to that the user has chosen.) However, it is just being blank.. nothing is getting populated. I must be missing something, or my approach is wrong. Does anyone know how to accomplish such a task? Thank you --David Zhu -- 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.
David Zhu wrote in post #972696:> Hello, > > I would like to have a link_to automatically populate a field in the > form that it is linking to. > > For example (excuse my silly words, im trying to make a point) > <%= link_to "Add a COOL Post", new_post_path, :howcoolisit => ''COOL'' > %> > <%= link_to "Add a NOTCOOL Post", new_post_path, :howcoolisit => > ''NOTCOOL'' %> > > Then, I would have a field in that form: > > <%= f.hidden_field :howcoolisit %> >Are you reading the params[:howcoolisit] value and assigning it to @post in the controller? -- 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-/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.
> Are you reading the params[:howcoolisit] value and assigning it to @post > in the controller?No I am not. How would I go about doing that? I don''t understand what you mean by "reading the params[:howcoolisit] value". -- 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.