Search code examples
ruby-on-railsviewactionview

Why isn't link_to filling the params correctly?


I'm generating links from the home page (controller = 'landings') via a partial containing:

<%= link_to t.to_s, assets_path, :name => t.to_s %>

where assets/index is the controller/method that I'd like to pass the :name to. However, after I've clicked the link, and control is thrown to the assets/index controller, params.to_s = "actionindexcontrollerassets"

I'd appreciate any help.


Solution

  • Extra parameters should be arguments to url/path helpers. This will do what you want:

    <%= link_to t.to_s, assets_path( :name => t.to_s) %>