Permalink
Browse files

views

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

0 comments on commit 1179bc2

Please sign in to comment.