Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to DSL to define custom filters #40

Merged
merged 1 commit into from
May 11, 2015
Merged

Conversation

Crunch09
Copy link
Contributor

Example:

filter :product_price_range do |relation, value|
    relation = relation.joins(:products)
    if value == 'low'
      relation.group("vendors.id").having('AVG(products.price) <= 100')
    elsif value == 'high'
      relation.group("vendors.id").having('AVG(products.price) > 100')
    end
end

Example:
```
filter :product_price_range do |relation, value|
 	relation = relation.joins(:products)
	if value == 'low'
  	relation.group("vendors.id").having('AVG(products.price) <= 100')
	elsif value == 'high'
  	relation.group("vendors.id").having('AVG(products.price) > 100')
	end
end
```
Crunch09 added a commit that referenced this pull request May 11, 2015
Add `filter` to DSL to define custom filters
@Crunch09 Crunch09 merged commit b448ebf into master May 11, 2015
@Crunch09 Crunch09 deleted the custom_filters branch May 11, 2015 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant