mysql is case-sensetive
This commit is contained in:
parent
2a3b0f74a3
commit
d4d534ee6b
|
@ -4,9 +4,9 @@ class AlbumsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:tag_id]
|
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]
|
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
|
else
|
||||||
@albums = Album.find(:all)
|
@albums = Album.find(:all)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,13 +4,13 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:tag_id]
|
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]
|
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]
|
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
|
else
|
||||||
@photos = Photo.find(:all, :order => "Photos.Id ASC")
|
@photos = Photo.find(:all, :order => "photos.id ASC")
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
Loading…
Reference in a new issue