Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

views

  • Loading branch information...
commit 1179bc2c864f2bcb8604f446368332315cc06c9f 1 parent 9bf84b5
Jonathan Weiss jweiss authored
2  app/controllers/photos_controller.rb
... ... @@ -1,6 +1,6 @@
1 1 class PhotosController < ApplicationController
2 2 def index
3   - @photos = Photo.find(:all, :include => :ratings)
  3 + @photos = Photo.all
4 4 @top_photos = Photo.find(:all, :limit => 3, :joins => :ratings, :group => 'ratings.photo_id', :having => 'ratings.value > 3')
5 5
6 6 respond_to do |format|
9 app/views/photos/_photo_line.html.erb
... ... @@ -0,0 +1,9 @@
  1 +<tr>
  2 +<% photos.each do |photo| %>
  3 + <td>
  4 + <a href="<%= photo_url(photo) %>">
  5 + <%= image_tag photo.body.url, :width => 60 %>
  6 + </a>
  7 + </td>
  8 +<% end %>
  9 +</tr>
11 app/views/photos/index.html.erb
@@ -8,7 +8,16 @@
8 8
9 9 <h1>All photos</h1>
10 10
11   - <%= render :partial => 'photos', :locals => {:photos => @photos} %>
  11 + <form method="post" action="/photos/search">
  12 + <input type="text" name="query" id="query">
  13 + <input type="submit" name="Search" value="Search">
  14 + </form>
  15 +
  16 + <table>
  17 + <% @photos.in_groups_of(4, false) do |group| %>
  18 + <%= render :partial => 'photo_line', :locals => {:photos => group} %>
  19 + <% end %>
  20 + </table>
12 21
13 22 <br />
14 23

0 comments on commit 1179bc2

Please sign in to comment.
Something went wrong with that request. Please try again.