Skip to content

bmihelac/rails-imfilters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Imfilters

Create named scopes for filtering.

class Book < ActiveRecord::Base
  belongs_to :author

  model_filter :name

  model_filter :published_on, :type => [:to_date, :from_date]

  # nested scope
  # scope 'filter_by_author_first_name', lambda {|val| joins(:author).where(
  # 'authors.first_name LIKE(?)', "%%#{val}%%")}
  model_filter [:author, :first_name]
  model_filter [:author, :country, :name]

  # gte, lte, gt, lt, eq
  model_filter :year_published, :type => [:gte, :lte, :gt, :lt, :eq]

  # in
  model_filter :author_id, :type => :in
end

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published