Skip to content

Instantly share code, notes, and snippets.

@johngrimes
Last active February 25, 2016 06:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johngrimes/6df379aed4c0162d792b to your computer and use it in GitHub Desktop.
def index
@areas = Area.all
@area = Area.find_by(slug: params[:area_slug]).presence || Area.find_by(slug: 'city')
conditions = { area: @area.subtree }
conditions.merge! params.select { |k,v|
[:bedrooms, :unit].include?(k) and !v.blank?
}
conditions[:property_type] = params[:type] || 'residential'
@properties = Property.includes(:area).where(conditions)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment