JonleePeakman
JonleePeakman

Reputation: 679

Add param to link_to show method

I have the current code in my traders.index.html file

<ul>
<% @traders.each do |trader| %>
  <li><%= link_to trader.name, trader %></li>
<%end%>
</ul>

I want to add an extra parameter to be sent through, I tried

<li><%= link_to trader.name, trader, {:restricted => params[:s]} %></li>

But this doesn't send the parameter, whats the actual format of the link_to to get this done?

Upvotes: 0

Views: 28

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51151

You can do:

<%= link_to trader.name, trader_path(trader, restricted: params[:s]) %>

Upvotes: 4

Related Questions