You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to implement a new ransacker for searching orders I couldn't find a way to add my ransacker method to the scopes whitelisted in the model
Context
In product_decorator.rb:
moduleNeospreemoduleSpreemoduleProductDecoratordefself.prepended(base)base.whitelisted_ransackable_scopes=%w[not_discontinuedsearch_by_nameline_items_contain_base_product]enddefline_items_contain_base_product(query)# my logic here...endendendendifSpree::Product.included_modules.exclude?(Neospree::Spree::ProductDecorator)Spree::Product.prependNeospree::Spree::ProductDecoratorend
I encountered this ticket after more than a year with the exact same issue. We actually made it work. Not sure if it follows the 'best practices', but it's better than nothing.
Anyway, I'm not sure how to use aforementioned approach:
And that's why we opted for a more explicit way. The following approach that's based on the link that @damianlegawiec provided above:
moduleNeospreemoduleSpreemoduleProductDecoratormoduleScopeFiltersdefline_items_contain_base_product(query)# my logic here...endenddefself.prepended(base)base.whitelisted_ransackable_scopes=%w[not_discontinuedsearch_by_nameline_items_contain_base_product]base.extend(ScopeFilters)endendendendifSpree::Product.included_modules.exclude?(Neospree::Spree::ProductDecorator)Spree::Product.prependNeospree::Spree::ProductDecoratorend
When trying to implement a new ransacker for searching orders I couldn't find a way to add my ransacker method to the scopes whitelisted in the model
Context
In product_decorator.rb:
Then in my view I've added it to the search form:
Expected Behavior
I expected that my field would be rendered and the method was found as a ransackable
Actual Behavior
An undefined method `line_items_contain_base_product' for #Ransack::Search:0x00007faddbdb45f8 occurs.
Your Environment
The text was updated successfully, but these errors were encountered: