link_to send parameters along with the url and grab them on target page

Just add them to link:

<%= link_to "Add Product", '/pages/product?param1=value1&param2=value2' %>

and in controller:

param1 = params[:param1] # "value1"
param2 = params[:param2] # "value2"

If you use helper methods for routes (for example company_path), then you can add hash of params, so this two should be similar:

<%= link_to "Add Product", new_product_path(:param1 => "value1", :param2 => "value2") %>
<%= link_to "Add Product", "/products/new?param1=value1&param2=value2" %>

From documentation:

link_to "Comment wall", profile_path(@profile, :anchor => "wall")
# => <a href="http://stackoverflow.com/profiles/1#wall">Comment wall</a>

link_to "Ruby on Rails search", :controller => "searches", :query => "ruby on rails"
# => <a href="http://stackoverflow.com/searches?query=ruby+on+rails">Ruby on Rails search</a>

link_to "Nonsense search", searches_path(:foo => "bar", :baz => "quux")
# => <a href="http://stackoverflow.com/searches?foo=bar&amp;baz=quux">Nonsense search</a>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)