model view controller - Rails: Link to custom method with variables -


i have simple custom method

def delete(foo, bar)   @foo = foo.find(foo)   @bar = bar.find(bar)   destroy end 

and want call view link:

<%= link_to 'delete', delete_articles_path(number: @number, tag: @tag), method: put, data: { confirm: 'are sure?' } %> 

the route:

  resources :articles      collection       put '/delete', to: "articles#delete", as: "delete_article"     end   end 

i tried like here(stack overflow) says should pass data through params, while want pass method variables.

you don't need arguments. pass variables need via params hash.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -