Can't mass-assign protected attributes: item

Hi!

I’m using the version of that gem GitHub - crowdint/acts_as_shopping_cart: Simple Shopping Cart implementation, Official repo: https://github.com/dabit/acts_as_shopping_cart for rails 3

I did evething with ythe convetions names. But I’m getting the error Can’t mass-assign protected attributes: item

class ShoppingCartsController < ApplicationController
before_filter :extract_shopping_cart

def create
@product = Video.find(params[:product_id])
@shopping_cart.add(@product, @product.price)
redirect_to shopping_cart_path
end

def show

Heres my model ShoppingCart

== Schema Information

Quick Google search brought up #26 Hackers Love Mass Assignment - RailsCasts and this StackOverflow question, ruby on rails - Can't mass-assign protected attributes - Stack Overflow.

Hi!

Thanks! but if you read the code below, you gonna see that my code is already have attr_accessible for all items.

Hi,

In the code you posted there is no “attr_accessible :item” is there?

Jan

Hi!

I tried, but the error persist.

Hi!

I tried, but the error persist.

Which version of Rails are you using? If it is 4 then you need to use strong parameters

Colin

Hi!

I'm using the version of that gem GitHub - crowdint/acts_as_shopping_cart: Simple Shopping Cart implementation, Official repo: https://github.com/dabit/acts_as_shopping_cart for rails 3

I did evething with ythe convetions names. But I'm getting the error Can't mass-assign protected attributes: item

I see item_id and item_type in your attr_accessbile list below, but not item.