Lifespan
This +lifespan+ extension provides filtering of record at the start_at and end_at.
Automatically adding to default_scope.
without_lifespan method a good job.
It is not erased only default_scope itself has added.
Installation
Add this line to your application's Gemfile:
TODO: It is scheduled to be able to support rubygem install
gem 'lifespan'
or
gem 'lifespan', github: 'gendosu/lifespan'
And then execute:
$ bundle
Or install it yourself as:
$ gem install lifespan
Usage
class Article < ActiveRecord::Base
lifespan start_at_column: "start_on"
end
How to use:
Article.all
=> SELECT
`articles`.*
FROM
`articles`
WHERE
(`articles`.`start_at` <= '2115-03-31 15:00:00.000072') AND
(`articles`.`end_at` > '2115-03-31 15:00:00.000072' OR `articles`.`end_at` IS NULL);
Development
TODO
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request