Reputation: 1078
I have a simple custom method
def delete(foo, bar)
@foo = Foo.find(foo)
@bar = Bar.find(bar)
destroy
end
And I want to call it from a view with the link:
<%= link_to 'Delete', delete_articles_path(number: @number, tag: @tag), method: put, data: { confirm: 'Are you sure?' } %>
The route:
resources :articles do
collection do
put '/delete', to: "articles#delete", as: "delete_article"
end
end
I tried like here(Stack Overflow) But it says that we should pass data through params, while I want to pass it to the method as variables.
Upvotes: 0
Views: 72
Reputation: 4443
You don't need arguments. Simply pass the variables you need via the params hash.
Upvotes: 1