I think the right way to do this is to use areas
scope :older_than, lambda { |value| where('id > (?)', value) if value } scope :with_id, lambda { |value| where('id = (?)', value) if value } scope :for_user, lambda { |value| where('user_id = (?)', value) if value }
later in the search
@photos = Photo.within(100, :origin => [params[:latitude], params[:longitude]]) unless (params[:latitude].nil? || params[:longitude].nil?) @photos = Photo.with_id( params[ :id ] ) .older_than( params[ :since_id ] ) .for_user( params[ :user_id ] ) .order("created_at DESC") .limit(15)
Bohdan
source share