Skip to content

Instantly share code, notes, and snippets.

@thomasv314
Forked from acidtib/explore_controller.rb
Created October 4, 2012 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasv314/3835327 to your computer and use it in GitHub Desktop.
Save thomasv314/3835327 to your computer and use it in GitHub Desktop.
@states = State.find(params[:id])
@towns = @states.towns.paginate(:page => params[:page], :per_page => 9).order("town")
@towns.each do |t|
t.postcards.last
t.postcards.count
end
end
<h1 class="pagetitle"><%= params[:state] %></h1>
<%= render 'layouts/search' %>
<div class="page_left">
<div class="ex_index">
<% @towns.each do |town| %>
<% if !town.postcards.empty? %>
<div class="span5 highlight">
<a href="/explore/state/town?town=<%= town.postcards.last.city %>">
<span class="btn pcount"><%= town.postcards.count %></span>
<span class="location-overlay"><%= town.town %></span>
<%= image_tag town.postcards.last.image_url(:featured), :class => "imgb image-shadow" %>
</a>
</div>
<% end %>
<% end %>
</div>
<div style="clear: both;"></div>
<div class="flickr_pagination">
<%= will_paginate @towns, :class => "page_paginate" %>
</div>
</div>
<%= render 'layouts/sidebar' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment