Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def self.search(agent, params)
- RealPropertySale.where(id: available_ids)
- .joins(:address)
- .by_state(state)
- .by_suburb(suburb)
- .by_post_code(post_code)
- .by_country(country)
- .paginate(page: page)
- end
- def self.by_state(state)
- where(addresses: {state: state})
- end
- def self.by_suburb(suburb)
- where(addresses: {suburb: suburb})
- end
- def self.by_post_code(post_code)
- where(addresses: {post_code: post_code})
- end
- def self.by_country(country)
- where(addresses: {country: country})
- end
- def self.by_state(state)
- return current_scope if state.nil?
- where(addresses: {state: state})
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement