Back

Rails add query parameters to format to link_to

added on :: 29 September 2014


<%= link_to "Expor CSV", producs_path({:format => :csv }.merge(params )) %>

to add extra information

<%= link_to "Export CSV", producs_path({:format => :csv }.merge(params)), :class => "btn btn-default " %>


or to select which parameters you would like to exclude

<%= link_to "Generate CSV", producs_path({:format => :csv }.merge(params.to_hash.except("controller", "action", "utf8").symbolize_keys!) ) %>


or to select which parameter you would include

<%= link_to "Generate CSV", producs_path(:format => :csv, :category => params[:category]) %>

Back