-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't mass-assign protected attributes: item #24
Comments
Could you show what your models for shopping_cart and shopping_cart_item ? |
Controller:
Heres my model ShoppingCart
and the model ShoppingCartItem
|
Unless you need the column fields like :owner_id, :owner_type, :quantity, :item_id, :item_type, :price to be accessible by the controller, you don't actually need attr_accessible for those fields. My code:
The items in the shopping cart are stored internally by the gem and there is no need for attr_accessible. |
Right. Thanks! But now, when I clik on
when I'm running and it redirect to shoping cart page, the item its not added to my cart. =( |
Should be
as your create action to add the item to cart is:
|
But my controller to this is:
|
In your ShoppingCartController, there is
|
Hi!! Thnaks by the gelp!! I'm getting it here: Couldn't find Video without an ID
|
I saw the log of passenger on my online server and it is returning this:
I'm using the gem "FriendlyId" for permalinks. i think it should be the cause of the error, incompatibility? |
I'm using this plugin with the convetions, but get this error:
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
The text was updated successfully, but these errors were encountered: