我正在使用该gem https://github.com/crowdint/acts_as_shopping_cart的版本用于rails 3
我使用约定名称做了所有事情。但我收到错误无法批量分配受保护的属性:item
class ShoppingCartsController < ApplicationController
before_filter :extract_shopping_cart
def create
@product = Video.find(params[:product_id])
@shopping_cart.add(@product, @product.price) # the error is generated on that line
redirect_to shopping_cart_path
end
我的模特ShoppingCart:
# == Schema Information
#
# Table name: shopping_carts
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
#
class ShoppingCart < ActiveRecord::Base
acts_as_shopping_cart
attr_accessible :price
#accepts_nested_attributes_for :price
end
我的模型ShoppingCartItem:
# == Schema Information
#
# Table name: shopping_cart_items
#
# id :integer not null, primary key
# owner_id :integer
# owner_type :string(255)
# quantity :integer
# item_id :integer
# item_type :string(255)
# price :float
# created_at :datetime not null
# updated_at :datetime not null
#
class ShoppingCartItem < ActiveRecord::Base
attr_accessible :owner_id, :owner_type, :quantity, :item_id, :item_type, :price
acts_as_shopping_cart_item
end
有谁可以帮助我,我在这里缺少什么?
答案 0 :(得分:0)
希望你知道
Rails 3
从版本0.2.0开始,不再支持Rails 3。如果您仍需要在Rails 3应用程序中实现此gem,请使用0-1-x分支
gem 'acts_as_shopping_cart', :github => 'crowdint/acts_as_shopping_cart', :branch => '0-1-x'