Ruby on rails 无法批量分配受保护的属性:项

Ruby on rails 无法批量分配受保护的属性:项,ruby-on-rails,ruby,ruby-on-rails-3,shopping-cart,Ruby On Rails,Ruby,Ruby On Rails 3,Shopping Cart,我正在使用适用于rails 3的gem版本 我用这些名字做了所有的事。但我得到了一个错误,无法批量分配受保护的属性:项 class ShoppingCartsController < ApplicationController before_filter :extract_shopping_cart def create @product = Video.find(params[:product_id]) @shopping_cart.add(@product, @

我正在使用适用于rails 3的gem版本

我用这些名字做了所有的事。但我得到了一个错误,无法批量分配受保护的属性:项

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
我的购物车模型:

# == 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
我的模型购物车项目:

# == 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
有人能帮我做点什么吗?

希望你能意识到这一点

轨道3

从版本0.2.0起,不再支持Rails 3。如果仍然需要在Rails 3应用程序中实现此gem,请使用0-1-x分支


您是否尝试将:item添加到attr\u accessible?是的,并接受\u嵌套的\u属性\u将其放在两个模型中,然后查看它的位置我看到了,我正在使用此版本。谢谢
gem 'acts_as_shopping_cart', :github => 'crowdint/acts_as_shopping_cart', :branch => '0-1-x'