diff --git a/app/models/album.rb b/app/models/album.rb index dae27e2..fe83a13 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -13,7 +13,7 @@ class Album < ActiveRecord::Base attr_accessor :tags attr_protected :path - named_scope :untouched, :conditions => "Albums.Id IN ( SELECT DISTINCT Photos.Album_Id FROM Photos WHERE Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags) )" + named_scope :untouched, :conditions => "albums.Id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags) )" def to_param "#{id}-#{title.parameterize}" diff --git a/app/models/photo.rb b/app/models/photo.rb index 54f56be..4ca7f0c 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -19,9 +19,9 @@ class Photo < ActiveRecord::Base attr_accessor :tag_list #attr_protected :path - named_scope :untouched, :conditions => "Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags)", :include => :album - named_scope :previous, lambda { |p,a| { :conditions => ["id < :id AND Album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "Id DESC"} } - named_scope :next, lambda { |p,a| { :conditions => ["id > :id AND Album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "Id ASC"} } + named_scope :untouched, :conditions => "photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags)", :include => :album + named_scope :previous, lambda { |p,a| { :conditions => ["id < :id AND album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "id DESC"} } + named_scope :next, lambda { |p,a| { :conditions => ["id > :id AND album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "id ASC"} } def self.search(q) if q