Forum: Ruby on Rails Including dynamic list of params in link_to

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Brandon Kelly (Guest)
on 2006-05-11 22:29
How do I include all incoming URL parameters (i.e.
list_content.rhtml?content_id=23) in my link_to statements?

I know I can include specific parameters in the link_to, by using
":variable_name => 123"  in the link_to statement...  But what If I
dont' know what the incoming parameters will be... and I simply want to
include them along with any other specific variables I choose.

I am using sortable columns in a table, and need to reload the page --
and I'm trying to use some common functions for this.. .but I'm getting
hung up with knowing what the incoming params are and including them on
all my links.
Lindsay B. (Guest)
on 2006-05-11 23:48
Brandon Kelly wrote:
> How do I include all incoming URL parameters (i.e.
> list_content.rhtml?content_id=23) in my link_to statements?
>

link_to :content_id => params[:content_id], :another =>
params[:another], :andanother => params[:andanother], etc

If a parameter is not sent in your http get request,  the param value is
nil, ie param[:another].nil? is true. Your logic in the controller's
action (eg 'list_content') should handle the different combinations of
parameter values.

Lindsay
This topic is locked and can not be replied to.