I have this content in a html.erb file. The file is referred to from some view files with render.
<table>
<tr>
<th>image</th>
<th>name</th>
<th>description</th>
<th>status</th>
<th>Options</th>
</tr>
<% @activities.each do |activity| %>
<% if activity.in? @activities_completed then next; end %>
<tr>
<td><%= image_tag activity.photo.url(:thumb) %></td>
<td><%= activity.name %></td>
<td><%= activity.description %></td>
<td><%= (activity.in?(@activities_gotten)) ? (image_tag "pending_activity.png") : (image_tag "missing_activity.png") %></td>
<td>
<% if activity.in? @activities_gotten %>
<%= button_to 'Remove', {:controller => :bucket_items, :action => :remove, :id => activity.id} %>
<% else %>
<%= button_to 'Add', {:controller => :bucket_items, :action => :add, :id => activity.id} %>
<% end %>
<%= button_to 'Show', activity , :method => :get %>
</td>
</tr>
<% end %>
</table>
the td with the buttons in the first iteration of the .each is rendered as:
<td>
<div>
<input type="submit" value="Add">
<input name="authenticity_token" type="hidden" value="KyR2ftDGxNti7bZ2zpW/V+UGYUbHpZ+efxX4h48a6L0=">
</div>
<form action="/activities/10" class="button_to" method="get">
<div>
<input type="submit" value="Show">
</div>
</form>
</td>
While the second and all the others:
<td>
<form action="/bucket_items/remove?id=13" class="button_to" method="post">
<div>
<input type="submit" value="Remove">
<input name="authenticity_token" type="hidden" value="KyR2ftDGxNti7bZ2zpW/V+UGYUbHpZ+efxX4h48a6L0=">
</div>
</form>
<form action="/activities/13" class="button_to" method="get">
<div>
<input type="submit" value="Show">
</div>
</form>
</td>
There's obviously a problem somewhere, as the first button won't work (obviously, there's no form tag around it), and that is the only one not working.
Any clue about what's happening here?
thanks,
I figured:
the erb I posted is the content of a partial, that is rendered from the actual view file.
The render command was contained already in a form_for function, therefore this was confusing Rails and giving the odd result.
solved,
thanks,