# Incrementing field through a link

**URL:** <https://www.ruby-forum.com/t/incrementing-field-through-a-link/164502>\
**Category:** Ruby\
**Created:** [April 2, 2009, 12:10am UTC](https://www.ruby-forum.com/t/incrementing-field-through-a-link/164502 "2009-04-02T00:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 2, 2009, 12:10am UTC](https://www.ruby-forum.com/t/incrementing-field-through-a-link/164502/1 "2009-04-02T00:10:18Z")

</div>

I’m still new to Ruby, so am having issues even beginning to deal with  
this. Tried doing some searches, but nothing turned up, and none of the  
tutorials that I ran through covered this. Anyway here’s my issue, we  
have a form that has a list of items. The last column in this form is a  
column (text field) for “quantity”. What I need to do is add a link to  
the side of this text field so that when someone clicks on it, it  
updates the quantity by 1. I already have a method to display this  
page, and another method to perform an update on it. However, I’m  
guessing (correct me if I’m wrong) I need to create a new method and  
access it by placing a link next to this text field. Here’s my text  
field code:

\<%= text\_field\_tag “order\_item” + i.to\_s + “[quantity]”, @quantities[i],  
:size =\> 3, :maxlength =\> 2 %\>  
\<%= link\_to ‘Add +’, :action =\> “add\_one” %\>

What I was thinking I had to do is make my “add\_one” method a  
combination of my “edit” and “update” methods. It doesn’t seem like  
this is the correct way of doing it, but I can’t think of anything else.  
Any suggestions? Thanks!

---

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 2, 2009, 5:28am UTC](https://www.ruby-forum.com/t/incrementing-field-through-a-link/164502/2 "2009-04-02T05:28:16Z")

</div>

On Wednesday 01 April 2009 17:10:15 Taneal Bhandari wrote:

> I’m still new to Ruby, so am having issues even beginning to deal with  
> this. Tried doing some searches, but nothing turned up, and none of the  
> tutorials that I ran through covered this. Anyway here’s my issue, we  
> have a form that has a list of items. The last column in this form is a  
> column (text field) for “quantity”.

Ruby does not have forms, items, or columns on its own. You probably  
want to  
ask the Rails list.

In the meantime, I’m going to suggest that you’re generating the link  
just  
fine, now you need to actually implement that action.

---

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 2, 2009, 6:09pm UTC](https://www.ruby-forum.com/t/incrementing-field-through-a-link/164502/3 "2009-04-02T18:09:09Z")

</div>

Cool. Thanks. Yeah, such a noob, didn’t even realize that I wasn’t  
posting in the appropriate forum. Thanks though.

Yeah, I think I kinda figured it out. Just realized that I can pass  
variable information through the link\_to method. That should work.
