1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00
danbarberphoto/app/controllers/photos_controller.rb
Dan Barber 85cf2fb4b8 Updated photos model to use named scopes. Cleaned up some code. Added
meta_where as a gem, although I'm not using it yet.
2010-12-14 12:51:34 -05:00

23 lines
629 B
Ruby

class PhotosController < ApplicationController
def new
@photo = Photo.new
@categories = Category.find(:all).map { |c| [c.name, c.id] }
end
def index
if params[:category_id]
@category = Category.find_by_id(params[:category_id])
@photos = @category.photos.enabled.paginate(:page => params[:page], :per_page => 11)
else
@photos = Photo.enabled.paginate :all, :page => params[:page], :per_page => 11
end
respond_to do |format|
format.html
end
end
def show
@photo = Photo.find(params[:id])
end
end