Jump to content

The ultimate community for Ruby on Rails developers.


Form: wrong ID

  • Please log in to reply
2 replies to this topic

#1 cmetzner



  • Members
  • 8 posts

Posted 11 November 2013 - 01:27 PM

I have the following problem:


Blindes Huhn Ticket - 52.00 Euro - <<"Hinzufügen"-Button>>

Early Bird Ticket - 59.00 Euro - <<"Hinzufügen"-Button>>



Whatever which Ticket i choose, my "addTicketID" is the ID of the last Ticket in the List.

Where is the Misstake in my Form-Tag?


Can someone help me?


<% @TicketList.each do |ticket| %>

<%= form_tag :action => 'addTicket' %>


<td style="padding: 5px; text-align: right;"><a href="/ticket/<%= ticket.id %>"><span><b><%= ticket.bezeichnung %></b></span></a></td>

<td style="padding: 5px; text-align: right;"><span><%= number_with_precision(ticket.preis, precision: 2) %> Euro</span></td>

<td style="padding: 5px; text-align: right;"> <%= submit_tag "Hinzufügen" %>

<input type="hidden" name="addTicketID" value="<%= ticket.id %>" />



<% end %>

#2 Ohm



  • Moderators
  • 529 posts
  • LocationCopenhagen

Posted 11 November 2013 - 02:47 PM

What is the generated output of this?


I would imagine it being something with the fact that all the forms will get the same css-id.


Do it have to be forms? Couldn't you just let the "Hinzufügen" button be a link with the id in it?

Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk

#3 cmetzner



  • Members
  • 8 posts

Posted 12 November 2013 - 01:46 PM

The output is a list of event-tickets.

i want to send the ticket-id for adding the right ticket to a cart.


or do you know a another possibility to handle this?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users