...">

How to add a parameter to remove a link?

I have a standard delete link and want to add a parameter to it:

<%= link_to "Delete", item, :confirm => 'Are you sure?', :method => :delete, :foo => 1 %> 

The parameter appears in the html a tag, but does not do it on the server. I get a local variable undefined or the `foo 'method."

This is how I access it in the controller:

 def destroy puts "params[:foo]:" + params[:foo].to_s . . . redirect_to edit_bar_path(params[:foo]) 

Output: params [: foo]:

+6
source share
2 answers
 <%= link_to "Delete", item_path(:id => item.id, :foo => 1), :confirm => 'Are you sure?', :method => :delete %> 
+14
source

I think you are looking for:

 item_path(item, :foo => 1) 

It should appear in your options

+3
source

Source: https://habr.com/ru/post/890799/


All Articles