diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index ec8e73a..fd05ba5 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -4,7 +4,7 @@ class AlbumsController < ApplicationController def index if params[:tag_id] - @albums = Album.find(:all, :conditions => [ "Id IN ( SELECT DISTINCT Photos.ALbum_id FROM Photos WHERE Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags WHERE Photo_Tags.Tag_Id = :q) )", { :q => Tag.find_by_title( params[:tag_id] ).id } ]) + @albums = Album.find(:all, :conditions => [ "Id IN ( SELECT DISTINCT Photos.ALbum_id FROM Photos WHERE Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags WHERE Photo_Tags.Tag_Id = :q) )", { :q => Tag.find( params[:tag_id] ).id } ]) elsif params[:q] @albums = Album.find(:all, :conditions => [ "Id IN ( SELECT DISTINCT Photos.Album_Id FROM Photos WHERE Photos.description LIKE :q OR Photos.title LIKE :q OR Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags LEFT OUTER JOIN Tags ON Photo_Tags.Tag_Id = Tags.Id WHERE Tags.Title LIKE :q) )", { :q => '%' + params[:q] + '%' } ]) else diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 7372901..e7f3349 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -36,11 +36,11 @@ class CollectionsController < ApplicationController end def edit - @collection = Collection.find_by_title( params[:id]) + @collection = Collection.find( params[:id]) end def update - @collection = Collection.find_by_title( params[:id]) + @collection = Collection.find( params[:id]) if @collection.update_attributes(params[:collection]) flash[:notice] = "Collection updated!" redirect_to @collection @@ -50,7 +50,7 @@ class CollectionsController < ApplicationController end def destroy - @collection = Collection.find_by_title( params[:id]) + @collection = Collection.find( params[:id]) if @collection.destroy redirect_to collections_path else diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index f19ea90..54cadad 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -4,9 +4,9 @@ class PhotosController < ApplicationController def index if params[:tag_id] - @photos = Tag.find_by_title( params[:tag_id] ).photos.find(:all, :order => "Photos.Id ASC") + @photos = Tag.find( params[:tag_id] ).photos.find(:all, :order => "Photos.Id ASC") elsif params[:album_id] - @photos = Album.find_by_title( params[:album_id]).photos.find(:all, :order => "Photos.Id ASC") + @photos = Album.find( params[:album_id]).photos.find(:all, :order => "Photos.Id ASC") elsif params[:q] @photos = Photo.find(:all, :limit => 20, :conditions => [ "Photos.description LIKE :q OR Photos.title LIKE :q OR Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags LEFT OUTER JOIN Tags ON Photo_Tags.Tag_Id = Tags.Id WHERE Tags.Title LIKE :q) ", { :q => '%' + params[:q] + '%' } ], :include => :album, :order => "Photos.Id ASC" ) else @@ -21,7 +21,7 @@ class PhotosController < ApplicationController def untouched if params[:album_id] - @album = Album.find_by_title( params[:album_id]) + @album = Album.find( params[:album_id]) @photos = @album.photos.untouched else @photos = Photo.untouched() @@ -51,7 +51,7 @@ class PhotosController < ApplicationController end def upload - @album = Album.find_by_title( params[:album_id]) + @album = Album.find( params[:album_id]) end def create diff --git a/features/step_definitions/album_steps.rb b/features/step_definitions/album_steps.rb index bb7d451..031bcb3 100644 --- a/features/step_definitions/album_steps.rb +++ b/features/step_definitions/album_steps.rb @@ -13,7 +13,7 @@ end Given /^I have albums titled (.+) in collection (.+)$/ do |titles,collection| titles.split(', ').each do |title| - CollectionAlbum.create( :collection => Collection.find_by_title(collection), :album => Album.create!(:title => title) ) + CollectionAlbum.create( :collection => Collection.find(collection), :album => Album.create!(:title => title) ) end end diff --git a/features/step_definitions/collection_steps.rb b/features/step_definitions/collection_steps.rb index 3da0509..9a7f949 100644 --- a/features/step_definitions/collection_steps.rb +++ b/features/step_definitions/collection_steps.rb @@ -13,5 +13,5 @@ Then /^I should have ([0-9]+) collections?$/ do |count| end Then /^collection (.+) should have ([0-9]+) albums?$/ do |collection,count| - Collection.find_by_title(collection).albums.count.should == count.to_i + Collection.find(collection).albums.count.should == count.to_i end \ No newline at end of file