Is it possible to create something cleaner out of this dynamic query:
@photos = Photo.within(100, :origin => [params[:latitude], params[:longitude]]) unl
I think the right way to do it is use scopes
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 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)