NoMethodError - Railscast 145 之后的路由中未定义的方法
我正在使用 Rails 3.1 并遵循此railscast来实施活跃商家,我'我尝试复制剧集中使用的购物车,但收到此错误:
没有方法错误
#Rails.root 的未定义方法“current_cart”: /用户/戴夫/工作/销售
应用程序跟踪|框架跟踪 |完整跟踪 config/routes.rb:7:in
<顶部(必需)>' 中的块(2 级) config/routes.rb:6:in
块中 ' config/routes.rb:1:in `' 这个错误 加载以下文件时发生:
/users/dave/work/sell/config/routes.rb
My Routes.rb
Sell::Application.routes.draw do
resources :orders
current_cart 'cart', :controller => 'carts', :action => 'show', :id => 'current'
resources :line_items
resources :carts
resources :products
end
Rails Cast 版本(查看 github 上的源代码)使用 |map| map.resources :无论以何种方式编写routes.rb。
感谢您的帮助,非常感谢!
I'm using Rails 3.1 and following this railscast to implement active merchant, I'm trying to copy the shopping cart used in the episode but am getting this error:
NoMethodError
undefined method `current_cart' for # Rails.root:
/users/dave/work/sellApplication Trace | Framework Trace | Full Trace config/routes.rb:7:in
block (2 levels) in <top (required)>' config/routes.rb:6:in
block in
' config/routes.rb:1:in `' This error
occurred while loading the following files:
/users/dave/work/sell/config/routes.rb
My Routes.rb
Sell::Application.routes.draw do
resources :orders
current_cart 'cart', :controller => 'carts', :action => 'show', :id => 'current'
resources :line_items
resources :carts
resources :products
end
The rails cast version (from looking at the source on github) uses the |map| map.resources :whatever way of writing the routes.rb.
Thanks for any help its much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试改变路线像
Try change route like