On 11 October 2010 20:32, Leonel *.* <[email protected]> wrote:
> I'm sorry, I usually try to stay away from the computer during weekends haha
>
> I tried the above but I get an error...
> <% @appointments.group_by
> { |appointment| appointment.start.strftime("%Y-%m-%d") }.each_pair do
> |start_date, appointments| %>
>
> <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 %>
>
> ERROR
> compile error
> .../app/views/appointments/index.html.erb:15: syntax error, unexpected '|',
> expecting '}'
> { |appointment| appointment.start...
Have you got a new line before the { ? It must all be on one line so
that ruby knows the { is the start of a block for the group_by call.
So the following all on one line:
<% @appointments.group_by { |appointment|
appointment.start.strftime("%Y-%m-%d") }.each_pair do |start_date,
appointments| %>
Colin
> ^
> .../app/views/appointments/index.html.erb:15: syntax error, unexpected '}',
> expecting kEND
> ...t.start.strftime("%Y-%m-%d") }.each_pair do |start_date, app...
>
> I want to understand what's going on, the each_pair, I'm a bit confused. In
> my controller, I have this:
> def index
> �...@appointments = Appointment.all(:order => 'start', :conditions => [
> "start >= ?", Date.today ] )
>
> So it's supposed to already have the appointments ordered by start datetime.
> --
> 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.
>
>
--
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.