ruby on rails - Invoking named routes helpers in views ends with NameError -
invoking named routes helpers in views ends nameerror following configuration:
routes.rb
:
scope :orders, as: :orders scope '/:order_id', as: :order post :returns, :to => 'order_returns#create' end end
$rake routes
:
orders_order_returns post /orders/:order_id/returns(.:format) order_returns#create
when add <%= orders_order_returns_path %>
template, rails
exit undefined local variable or method 'orders_order_returns_path' #<#<class:0x007faec10fe728>:0x007faec10dc8d0>
...
executing rails.application.routes.named_routes.helpers.map(&:to_s)
in console on exception page returns:
["spree_path", "orders_order_returns_path", "rails_info_properties_path", "rails_info_routes_path", "rails_info_path", "rails_mailers_path", "spree_url", "orders_order_returns_url", "rails_info_properties_url", "rails_info_routes_url", "rails_info_url", "rails_mailers_url"]
my question is: why using named routes path/url helpers in view ends exception when visible in consoles ?
i found answer here:
because you're calling inside spree template need prefix
main_app.
,main_app.products_starting_with_path
here's release note spree:
conversely, reference routes main application within controller, view or template spree, must use
main_app
routing proxy
using main_app
routing proxy solved described problem :)
Comments
Post a Comment