[Rails] Re: button_to (passing paramters again)

2017-02-16 Thread Joe Guerra
ok, still confused I've defined my parms like this... def cart_params # params.fetch(:cart, {}) params.require(:cart).permit(:user_id, :product_id ) end Have this in my controller. def add_to_cart product_id = params['id'] user_id = session['user_id'] @cart = Cart.new(us

[Rails] Re: button_to (passing paramters again)

2017-02-15 Thread Scott Jacobsen
Controller action methods do not take parameters. You get the parameters from the `params` hash. Also, as was mentioned, do not send user_id as a param. It is a security error, and you don't need to because you can access the session in the controller: def add_to_cart product_id = params["pro