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

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 -