I'm trying to code a table listing appointments. I just want to display
a particular date in a table row once, then list all the appointments
for that day. The display tomorrow's date in a row once and then list
all the appointments for that day, and so forth.
I have the following code, but it's not working. Seems like the new_date
= 1 statement doesn't work. What am I doing wrong?
<table id="table_appointments"
<tr>
<th>Client</th>
<th>Service</th>
<th>When</th>
<th></th>
<th></th>
<th></th>
</tr>
<% new_date = 0 %>
<% current_date = Date.today %>
<% @appointments.each do |appointment| %>
<% if new_date == 0 %>
<tr><th colspan="6"> <%= new_date %> | <%= current_date %> | <%=
appointment.start.strftime("%Y-%m-%d") %></th></tr>
<% end %>
<% if current_date == appointment.start.strftime("%Y-%m-%d") %>
<% new_date = 1 %>
<% else %>
<% new_date = 0 %>
<% end %>
<tr class="<%= cycle('list_line_odd', 'list_line_even') %>">
<td><%= appointment.client.name %></td>
<td><%= appointment.service.name %></td>
<td><%= appointment.start.strftime("%A %b %d %Y at %I:%M %p")
%></td>
<td><%= link_to 'Show', appointment %></td>
<td><%= link_to 'Edit', edit_appointment_path(appointment) %></td>
<td><%= link_to 'Destroy', appointment, :confirm => 'Are you sure?',
:method => :delete %></td>
</tr>
<% end %>
</table>
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.