Skip to content

Instantly share code, notes, and snippets.

@acidtib
Created August 27, 2012 17:58
Show Gist options
  • Save acidtib/3490866 to your computer and use it in GitHub Desktop.
Save acidtib/3490866 to your computer and use it in GitHub Desktop.
controller
def explore
@states = State.find(params[:id])
@towns = @states.towns.paginate(:page => params[:page], :per_page => 9)
#@towns.each do |t|
@towns.each {|t| if t.postcards.empty? @towns.delete(t) end }
t.postcards.last
end
end
<% @towns.each do |town| %>
<div>
<%= town.town %> -
<%= town.postcards.last.eat %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment