简体   繁体   中英

Using filterrific with API

I am attempting to use filteriffic in an application only for the real time search.
The application does not have a database serves everything by communicating with an API.
This is in my controller:

@filterrific = initialize_filterrific(
    call_api("/api/v1/site_links", {search: params[:search]}),
    params[:filterrific],
    select_options: {
    },
    persistence_id: 'mike',
    default_filter_params: {},
  ) or return
  @site_links

  respond_to do |format|
    format.html
    format.js
  end

Right now I do not have a model related to this controller.
Whenever I try to load the page I get:

undefined method `filterrific_default_filter_params' for 

I am using filterrific 2.0.5 and rails 4.2.0

According to the Filterrific documentation , it is designed specifically for ActiveRecord models.

The call to initialize_filterrific requires a model class as the first parameter, which is eventually used to call model_class.filterrific_default_filter_params . This is why you're getting the error.

I've had success creating live search with the rails4-autocomplete gem .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM