I’m a bit rusty with Rails. I’m trying to create a route that should accept an arbitrary number of parameters from a link_to, but I keep getting routing errors.
My link currently looks like this:
<%= link_to "Send Params", :action => "recieve", :controller => "pages", :name => "Test", :email => "test2" %>
And my route looks like this:
match 'pages/receive/*params' => 'pages#receive'
And I get:
No route matches {:action=>"recieve", :controller=>"pages", :name=>"Test", :email=>"test2"}
If I do:
<%= link_to "Send Params", :name => "Test", :email => "test2" %>
And:
match '/*params' => 'pages#receive'
It kinda works, but my method in the controller isn’t getting called.
So, how should the route and link_to look?
Correct me if I’m wrong, but I think there is no need in this
*paramsin you routes. You can do like that:In Rails
paramsis a helper method (that you can use in controllers and views) that returns a hash containing all GET and POST parameters.