Filterrific, Initializing multiple models in the controller for one view

The flexibility associated with Filterrific annoys me.

But I'm wondering how you can handle filtering multiple ActiveRecord models in one view.

Is there a way to add multiple models to the filterrific instance variable when initializing in the controller?

Therefore, instead of passing one model class, as in the code example below, adding additional model classes.

@filterrific = initialize_filterrific(
  Student, #add another set of parameters for a second model somewhere here
  params[:filterrific],
  select_options: {
    sorted_by: Student.options_for_sorted_by,
    with_country_id: Country.options_for_select
  },
  persistence_id: 'shared_key',
  default_filter_params: {},
  available_filters: [],
) or return

If it is not possible to add multiple models, is there another way to handle a scenario that requires filtering based on multiple models? Maybe additionally initialize filtering in a separate instance variable?

Thanks!

+4

Source: https://habr.com/ru/post/1609286/


All Articles