Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from anonymous/_booking_dialog.html.erb
Created December 18, 2012 22:32
Show Gist options
  • Save radar/4332701 to your computer and use it in GitHub Desktop.
Save radar/4332701 to your computer and use it in GitHub Desktop.
<% @hospitals.each do |hospital| %>
<% hospital.hospital_bookings.each do |booking| %>
@safarista
Copy link

If I want to get the first or second booking
Is this how to do it?

<% @hospitals.each do |hospital| %>
  <%= fb = hospital.hospital_bookings.first %>

OR
<% @hospitals.each do |hospital| %>
  <%= fb = hospital.hospital_bookings.try(:find, :first) %>

Thats pretty.

Whats the difference in result/errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment