DmFilter
DmFilter is a very light weight Rails plugin that makes it easy to fetch your ActiveRecord lists using date or text as a parameter.
Installation
Add this line to your application's Gemfile:
gem 'dm_filter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dm_filter
include this into your model
include DmFilter
example
class Invoice < ApplicationRecord
include DmFilter
end
Usage
Values for duration
-
all
(default) today
yesterday
this_week
this_month
last_month
period
Available options
-
duration
(default isall
) -
from
(ifday
is equal toperiod
) -
to
(ifday
is equal toperiod
) -
column_date
(default iscreated_at
)
Example
# specifying column_date
Invoice.dm_get(duration: 'today', column_date: 'paid_at')
or simply
# default column_date is created_at
Invoice.dm_get(duration: 'today')
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/denmarkmeralpis/dm_filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.