routing - Rails 5 link_to specific controller action -
i have following routing problem in rails 5:
<%= link_to product.id, product %> generates link
localhost:3000/products/12345
what want link "ext" action in products controller:
localhost:3000/products/ext/12345
if try build link
<%= link_to 'to product', :controller => :products, :action => :ext %> it gives following error:
no route matches {:action=>"ext", :controller=>"products"}
in routes.rb have
"products/ext/:id", to: "products#ext" thanks help!
modify routes
get "products/ext/:id", to: "products#ext", as: :products_ext and change view to
<%= link_to products_ext_path(product) %>
Comments
Post a Comment