Cart creation 中的Ruby session问题

在学习RubyOnRails的过程中,使用Rails2.0.2版本遇到问题。在尝试实现购物车创建功能时,代码出现页面无法找到错误。通过添加模型声明后,又遇到undefined method 'model'的NoMethodError错误。问题来源于对Rails2.0.2控制器中模型加载语法的误解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚开始学Ruby On Rails 看的是那本经典的 Agile Web Development...
我用的是rails 2.0.2
在cart creation一章中我写的所有的代码都没有问题,除了开始的错误是“页面无法找到”。
上网查了一下说是用如下的解决方式即加上两行代码
"model :cart
model :line_item"

如下:

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
 
 
  helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '00df83fd9a7c900f90067f3893d03eb7'\

 
  model :cart
  model :line_item


end

可是再次运行就报了这么一个错误:

NoMethodError
undefined method `model' for ApplicationController:Class

RAILS_ROOT: E:/temp/demoNetBean

转载于:https://www.cnblogs.com/anshangcun/archive/2008/08/19/1270723.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值