From d4d534ee6b6367c34418843b3abec6a272dcb33c Mon Sep 17 00:00:00 2001 From: Espen Antonsen Date: Tue, 16 Jun 2009 01:43:53 +0200 Subject: [PATCH] mysql is case-sensetive --- app/controllers/albums_controller.rb | 4 ++-- app/controllers/photos_controller.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index fd05ba5..ce800c9 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -4,9 +4,9 @@ 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( 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] + '%' } ]) + @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 @albums = Album.find(:all) end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 54cadad..cdc522b 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -4,13 +4,13 @@ class PhotosController < ApplicationController def index if params[:tag_id] - @photos = Tag.find( 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( 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" ) + @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 - @photos = Photo.find(:all, :order => "Photos.Id ASC") + @photos = Photo.find(:all, :order => "photos.id ASC") end respond_to do |format| format.html