ceth
ceth

Reputation: 45285

Pass parameter from view to controller

I have a next code in my view:

<% @todos.each do |todo| %>
  <tr>
    <td><%= todo.description %></td>
    <td><%= link_to 'Create action', new_simple_action_path } %></td>

I want to pass todo.description to SimpleAction-controller. I can rewrite my code like this and it will be work:

<td><%= link_to 'Create action', { :controller => 'simple_actions', :action => 'new', :todo => todo.description } %></td>

But I'm just wondering if is it possible to pass variable as parameter using new_simple_action_path ?

Upvotes: 0

Views: 1363

Answers (1)

Heikki
Heikki

Reputation: 15417

This should work:

link_to 'Create action', new_simple_action_path(:todo => todo.description)

Upvotes: 2

Related Questions