Re: [Rails] button_to (passing paramters again)

2017-02-28 Thread Joe Guerra
I finally got it working. I went to a local ruby on rails meetup and got some help on the issue. I needed to use current_user.id and params[:product_id] for my parameters in my function. Thanks, Joe On Thursday, February 16, 2017 at 5:51:29 PM UTC-5, Walter Lee Davis wrote: > > > > On Feb 16

Re: [Rails] button_to (passing paramters again)

2017-02-16 Thread Walter Lee Davis
> On Feb 16, 2017, at 9:27 AM, Joe Guerra wrote: > > 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

Re: [Rails] button_to (passing paramters again)

2017-02-15 Thread Hassan Schroeder
On Wed, Feb 15, 2017 at 4:11 PM, Joe Guerra wrote: > I've got this in my product show pageI'm trying to pass user_id & > product_id to my products controller, add_to_cart method... Accepting user_id as an untrusted input from the client is a Very Bad Idea. If it's a value saved in session yo

[Rails] button_to (passing paramters again)

2017-02-15 Thread Joe Guerra
I am pretty close to figuring this out... I've got this in my product show pageI'm trying to pass user_id & product_id to my products controller, add_to_cart method... <%= button_to 'Add to Cart', {:controller => "products", :action => "add_to_cart", :user_id=> session[:user_id], :product