Project

drafteable

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Drafteable is a super simple and opinionated ActiveRecord model draft behavior encapsulation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.11.0

Runtime

~> 3.2.8
 Project Readme

Drafteable Build Status

Drafteable is a super simple and opinionated ActiveRecord model draft behavior encapsulation:

A drafteable model should:

  • Provide a boolean field as a flag for its draft status.
  • Provide methods to check draft or published status.
  • Provide methods to change draft or published status.

Right now, this gem provides the last two points. You should generate the appropriate migration to add a draft column. Something like:

add_column :posts, :draft, :boolean, default: false

Installation

Add this line to your application's Gemfile:

gem 'drafteable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install drafteable

Usage

On your ActiveRecord model add

acts_as_drafteable

Then you get published?, draft? (for checking the state) and publish!, draft! (for changing the status).

Note that calling draft! will save the model skipping validations.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

You've got test under spec/ and bundle install should take care of all gem dependencies for development.

TODO

  1. Write generator to create migration with draft field on model.