Rails named route & helper (/controller/:id/randomname) -
i'm trying following routing work:
get 'items/:id/pictures' => 'pictures#show' what kind of helper method should use ? using <%= link_to pictures_item_path %> following error:
undefined local variable or method `pictures_item_path' #<#<class:0x007fa2c6181710>:0x007fa2c40ba7c0> i've tried using get 'items/:id/pictures' => 'pictures#show', as: 'items/:id/pictures' , following error:
invalid route name: 'items_:id_pictures'
your route correct. if you're going use helper, have use named routes.
routes can named passing :as option, allowing easy reference within source name_of_route_url full url , name_of_route_path uri path:
# in routes.rb '/login', to: 'accounts#login', as: :login # render, redirect_to, tests, etc. redirect_to login_url i hope helpful.
Comments
Post a Comment