Would like ability to use scope with param
Closed this issue · 11 comments
like: scope :model_scope, name: 'GeneralScope', attr: :input
Well I'm not sure if this is what you're looking for since your question is not really elaborate ;-) . But I added an example to the demo app
FortySource/forty_facets_demo@e9c784e
Unfortunately I could not deploy it yet to heroku yet because of their db row limits
I also a release a new gem version with more robust param handling
hth
Would like the ability to use an argument with scope
.
So model looks like: scope :cars, ->(type) { where('auto = ?', type') }
Search class like: scope :cars
.
And scope
accepts argument if required.
@axelerator
me too,
i wouldl like to this scope with a parameter in the model. Any help?
scope :with_campaign_id, ->(campaign_id) { where(campaign_id: campaign_id) }
@axelerator any help? :) 👍
But where is the campaign_id value supposed to come from?
in your readme you have
scope :classics # only return movies which are in the scope 'classics'
i would like to be able to do:
scope :with_campaign_id, # only return campaigns with a specific ID
@search = CompanySearch.new(params) #.filter(:with_campaign_id).add(params[:campaign_id])
@axelerator do you see what i mean?
And why don't you just use a facet then?
facet :campaign_id
or
facet :campaign
@axelerator because even if i use facet for campaign, others facets count will display wrong Total count. doesnt make sense ?
lets give an example
I have 2 campaigns. In campaign A, i have 1 company founded in the year 1930 and 1 company founded in 1949. In campaign B, i have only one company founded in 1949.
founded_year facet will display
1930 (2)
1949 (1)
With a Scope campaign A, I would like the plugin display founded_year facet:
1930 (1)
does that make sense @axelerator ?
If you have a facet for campaign and year, with the data you give, you should get the facets
Campaign:
A (2)
B (1)
Year-Facet
1930 (1)
1949 (2)
Once you Filter on campaign: A the number of 1949 will decrease since the company with campaign B founden in 1949 is not anymore in the result.
Compare i.e. http://forty-facets-demo.herokuapp.com/
When you filter a year the values for Genres will decrease
@axelerator wonderful. thank you so much!