Ive been staring at this for a good day now and i dont understand what ive done wrong. i want this to produce a list of activities with checkboxes, but if one of the activities is in the users_activity table then that that activities check box will be checked. However the code below displays the activity three times and chekcs all the boxes.
<fieldset>
<table>
<tr>
<th>Activity ID</th>
<th>Activity Name</th>
</tr>
<% @Activitys.each do |activity| %>
<% @users_activity.each do |ua| %>
<% if activity.id == ua.activity_id %>
<tr>
<td><%= activity.id %></td>
<td><%= activity.activity_name%></td>
<td><input name="check_<%= activity.id %>" type="checkbox" checked="yes"></td>
</tr>
<% else %>
<tr>
<td><%= activity.id %></td>
<td><%= activity.activity_name%></td>
<td><input name="check_<%= activity.id %>" type="checkbox" checked="no"></td>
</tr>
<% end %>
<% end %>
<% end %>
</table>
</fieldset>
Its probably really easy but you know what happens when you stare at a piece of code for too long...