Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Module for mixing in date related scopes to ActiveRecord models
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
gemfiles
lib
spec
.gitignore
.ruby-gemset
.ruby-version
.travis.yml
Appraisals
CHANGELOG.md
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
include_date_scopes.gemspec

README.md

include_date_scopes

Build Status

An ActiveRecord module for automatically including a large list of commonly used date related scopes.

Usage

To use in a model on the standard created_at column, put the include_date_scopes call in your class:

class Post < ActiveRecord::Base
  include_date_scopes
end

Now you can call scopes like Post.after(1.week.ago) or Post.yesterday.

If you wish to use this on another column, use include_dates_scopes_for:

class Post < ActiveRecord::Base
  include_date_scopes_for :show_at
end

Now all of the provided scopes will work with the show_at column.

If you want to include multiple sets of date scopes, you can use named date scopes:

class Post < ActiveRecord::Base
  include_named_date_scopes_for :updated_at
end

Now the scopes will all be prepended with updated_at_. So Post.yesterday would become Post.updated_at_yesterday.

Something went wrong with that request. Please try again.