Ruby on Rails Wednesday, January 5, 2011

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@googlegroups.com.
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.

No comments:

Post a Comment