Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module SendAll
- def send_all(methods_and_args)
- return self if methods_and_args.empty?
- method_name, args = methods_and_args.pop
- result = send method_name, *args
- result.send_all result, query
- end
- end
- class ActiveRecord::Relation
- self.instance_eval { include SendAll }
- end
- Developer.send_all [
- [:with_interest_bucket_ids_including, [1,2,3]],
- [:with_location_bucket_ids_includint, [3,4,5]]
- ]
- # This could then be used in controllers to chain scopes depending on a query
- Developer.send_all developer_params.to_a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement