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.
Student model is the primary model which we will filter. It belongs to
Country class as shown below:
Student class is our primary class. This is where we include Filterrific.
1 2 3 4 5 6 7 8 9 10 11 12 # 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 class represents the country a
Student belongs to, e.g.,
“Canada”, “United States”, and “Australia”.
Not all students belong to a country.
1 2 3 4 5 6 7 8 # app/models/country.rb class Country < ActiveRecord::Base # db columns: # integer: id # string: name has_many :students end