berk / will_filter

rails engine plugin for filtering active_record model objects
MIT License
157 stars 76 forks source link

Rails 5.0.1 > undefined method 'wf_filter=' #64

Open prathees opened 7 years ago

prathees commented 7 years ago

I am getting the below error when using will_filter in Rails 5.0.1

> MyModel.filter params:p undefined method `wf_filter=' for #\<MyModel::ActiveRecord_Relation:0x007fb1f9ec8580>

The error trace shows the following snippet @ app/models/will_filter/filter.rb

        recs = recs.page(page).per(per_page)
        recs.wf_filter = self
        recs

PS: Skipping this assignment 'recs.wf_filter = self' can solve the problem, but if the project uses the view components from this gem, there could be some breakage. (refer: results.add_filter_condition @ app/views/will_filter/common/_results_table.html.erb)

prathees commented 7 years ago

Fixed this in my forked branch : https://github.com/prathees/will_filter by adding the 'wf_filter' related methods to ActiveRecord::Relation via extension