Consider the requirement that a model should have a filter declared for each attribute and each assosciation. I don't want to manually whitelist all filters in each model since I know the rule - model should declare with\${attribute_name or associationname} filters.
I have decided to move filterrific initialization to rails initializer. Why? Because at this stage all models are loaded and I can safely access information about its attributes and associations using some reflection methods/metaprogramming in order to compose array of filter names.
in initializers/filterrific.rb - although it does not raise any error, it does not seem to successfully initialize filterrific. It raises an error "undefined method filterrific default_filter params'" when controller tries to apply filters.
Suprisingly when I do the same in models/car.rb under the class scope (outside of it) everything does work..
For some reason filterrific is not able to decorate model class with necessary methods when called this way from other file..Could anyone explain this behaviour? Thank you in advance.
Consider the requirement that a model should have a filter declared for each attribute and each assosciation. I don't want to manually whitelist all filters in each model since I know the rule - model should declare with\${attribute_name or associationname} filters.
I have decided to move filterrific initialization to rails initializer. Why? Because at this stage all models are loaded and I can safely access information about its attributes and associations using some reflection methods/metaprogramming in order to compose array of filter names.
However, when I do i.e
Car.filterrific(available_filters: array_of_available_filter_names)
in initializers/filterrific.rb - although it does not raise any error, it does not seem to successfully initialize filterrific. It raises an error "undefined method filterrific default_filter params'" when controller tries to apply filters.
Suprisingly when I do the same in models/car.rb under the class scope (outside of it) everything does work..
For some reason filterrific is not able to decorate model class with necessary methods when called this way from other file..Could anyone explain this behaviour? Thank you in advance.