Incrementing field through a link

  • Thread starter Taneal Bhandari
  • Start date
T

Taneal Bhandari

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,
: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!
 
D

David Masover

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.
 
T

Taneal Bhandari

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top