The Ruby on Rails experts
Logo_144 ClearCove Software, Inc. :: Filterrific

All patterns and instructions in this documentation refer to the filterrific demo Rails application below. You can view a live demo, and the source for the demo app.

I have included only the parts of the code required to demonstrate Filterrific. In a production app you would have to add a lot more code to handle permissions, strong params, etc.

The Student model is the primary model which we will filter. It belongs to the Country class as shown below:

Class structure

Example application class structure

Class structure of the example application

Student

The Student class is our primary class. This is where we include Filterrific.

# app/models/student.rb
class Student < ActiveRecord::Base
  # db columns:
  # integer: id
  # string: first_name
  # string: last_name
  # text: email
  # integer: country_id
  # datetime: created_at

  belongs_to :country
end

Country

The Country class represents the country a Student belongs to, e.g., “Canada”, “United States”, and “Australia”.

Not all students belong to a country.

# app/models/country.rb
class Country < ActiveRecord::Base
  # db columns:
  # integer: id
  # string: name

  has_many :students
end

Learn about the Model API →