No commit activity in last 3 years
No release in over 3 years
providing some helpful methods for ActiveRecord relate to Date class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

ActiveRecord Datepicker

Some Useful date-picking methods for ActiveRecord. probably support more methods in future.

What does this do?

Providing familiar Date or DateTime class methods for ActiveRecord class.

Installation

Add this line to your application's Gemfile:

gem 'activerecord-datepicker'

or install standalone

gem install 'activerecord-datepicker'

require 'activerecord-datepicker'

Usage

Include Datepicker module in ActiveRecord Models

class Post < ActiveRecord::Base
  include Datepicker::Model
end

Date-picking records

# filter by specific date
some_date = Date.new 2018, 4, 13
Post.pick_date some_date

# filter by date range
from = Date.new 2018, 4, 01
to   = Date.new 2018, 4, 30
Post.pick_date (from..to)

# listing today's records 
Post.today       

Post.all.first.today?    

Custom column

The default date picking column will be :created_at which was given by active record itself, you can setup custom date picking column.

class Post < ActiveRecord::Base
  include Datepicker::Model
  self.datepick_on = :posted_date
end

License

The gem is available as open source under the terms of the MIT License.