Re: [Rails] how do you pass paramters from a button in rails?

2017-02-07 Thread Greg Navis
D'oh! Thanks for correcting me, Hassan. I consulted the docs but somehow
completely missed that.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt-zPUK_Bu4ww9qrksWdkGoSwFgo1xbZbpNgLRw0u%2BGTFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] how do you pass paramters from a button in rails?

2017-02-04 Thread Scott Eisenberg
You can put the parameters as an argument to a path like so:

=link_to "Add Special", add_special_path(work_day: @date), class: 'uk-button 
buffer-left-twice’ which will make a url like

http://xxx.com/time/add_special?work_day=2017-02-04 


Or if you have a model that is already in the button, you put parameters after 
it like:

%= link_to 'Confirm my account', confirmation_url(@resource, 
:confirmation_token => @token)

This is from Devise on their default views




> On Feb 4, 2017, at 10:13 AM, Hassan Schroeder  
> wrote:
> 
> On Sat, Feb 4, 2017 at 12:13 AM, Greg Navis  wrote:
>> button_to generates a form with a button. I'm not sure there's a way to add
>> custom hidden fields to the form. One way around the problem would be to
> 
> One way around the "problem" would be to read the documentation
> for that method, which includes under "options"
> 
> :params - Hash of parameters to be rendered as hidden fields within the form.
> 
> FWIW,
> -- 
> Hassan Schroeder  hassan.schroe...@gmail.com
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAUOpp1nTzPOptHvOEX0td-do72Zq-qetytsbpwVWEY5Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/97ED9DDB-D9DC-4F1B-A9DF-BBE5337247D0%40btrtrucks.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] how do you pass paramters from a button in rails?

2017-02-04 Thread Hassan Schroeder
On Sat, Feb 4, 2017 at 12:13 AM, Greg Navis  wrote:
> button_to generates a form with a button. I'm not sure there's a way to add
> custom hidden fields to the form. One way around the problem would be to

One way around the "problem" would be to read the documentation
for that method, which includes under "options"

 :params - Hash of parameters to be rendered as hidden fields within the form.

FWIW,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAUOpp1nTzPOptHvOEX0td-do72Zq-qetytsbpwVWEY5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] how do you pass paramters from a button in rails?

2017-02-04 Thread nanaya
Hi,

On Sat, Feb 4, 2017, at 12:52, Joe Guerra wrote:
> 
> 
> I have the following code in my show.html.erb file, it calls the right
> method (or path).  
> 
> I am unsure how to pass variables from my product show.html.etb to my
> actual method... 
> 
> 
> 
> <%= button_to 'Add to Cart', add_to_cart_path, method: :post %>
> 
> 
> I need to pass the product id, and possibly qty.
> 

Add it as part of the url (something like `add_to_cart_path(product_id:
product.id, quantity: 1)`). If you need the quantity to be taken from an
input box then make a form instead of just a button.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1486197001.3407873.870045232.270AC06F%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] how do you pass paramters from a button in rails?

2017-02-04 Thread Greg Navis
button_to generates a form with a button. I'm not sure there's a way to add
custom hidden fields to the form. One way around the problem would be to
create the form manually, add the hidden input (with product ID), a number
input with quantity and the submit button.

Would this work for you?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt-zgzJLQxy5eZ%3D8dcNhh-GWsLpK%2BKbX2kkbFq-znm_S-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] how do you pass paramters from a button in rails?

2017-02-03 Thread Joe Guerra


I have the following code in my show.html.erb file, it calls the right method 
(or path).  

I am unsure how to pass variables from my product show.html.etb to my actual 
method... 



<%= button_to 'Add to Cart', add_to_cart_path, method: :post %>


I need to pass the product id, and possibly qty.


Thanks,

Joe

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/fc5ba368-9ad8-4572-8f8c-af6e761127cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.