开发者

How to add parameter to delete link?

开发者 https://www.devze.com 2023-03-13 23:53 出处:网络
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 %>

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 shows up in the html a tag, but does not make to the server. I get "undefined local variable or method `foo'".

Here is how I am accessing it in the controller:

def destroy
    puts "params[:foo]:" + params[:foo].to_s 
    .
    .
    .
    redirect_to edit开发者_开发问答_bar_path(params[:foo])

The output is params[:foo]:


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


I think you are looking for:

item_path(item, :foo => 1)

It should appear in your params

0

精彩评论

暂无评论...
验证码 换一张
取 消