Try the following: In the update method, replace
if @cart.update_attributes(params[:cart])
if @cart.update_attributes(cart_params)
In your private cart_params method, do the following:
def cart_params params.require(:cart).permit(:attribute1, :attribute2, :attribute3) end
With Rails 4, the concept of strong parameters was introduced, which basically prohibits the mass assignment of attributes in the controller. This means that the mass protection that was once in the model (attr_accessible) is now moved to the controller. Therefore, in your models you need no more :
attr_accessible :attribute1, attribute 2 #attributes that can be mass-assinged attr_protected :attribute3 #attribute that is protected and cannot be mass-assinged
Instead, you can do this in your controller via:
params.require(:cart).permit(:attribute1, :attribute2, :attribute3)
This means that only attribute1, attribute2. basket attribute 3 is available, while others are protected attributes
source share