Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Publications

Publications is a library for Rails, enabling you to easily add publication control to your models. You can control publication based on activation and deactivation dates, a boolean flag, or a combination of both.

Support is included for CRUD runtime generators (such as ActiveAdmin, ActiveScaffold)

Installation

Just add this to your Gemfile:

gem"publications"

(you can also install the gem directly with: gem install publications)

Overview

After Publications is installed, it's easy to add publication support to your models. Just add this to your class:

has_publish_control

Example:

classBookhas_publish_control# This is all it takes :)end

You'll be able to do the following:

book=Book.newbook.active=truebook.activated_at=10.days.from_nowbook.disabled_at=20.days.from_nowbook.save!Book.active# will return all active books Book.all# will return only published books, if creation of a global scope has been enabled

Migrations

A few columns will be needed in your tables to handle publications. To add them, just add the following to your migrations (either on createtable or changetable):

t.publications

Example

classAddPublicationsToBooks < ActiveRecord::Migrationdefself.upcreate_table:booksdo |t|
t.publicationsendenddefself.down#TODOendend

Configuration

The following options allow you to configure Publications to fit your needs:

:default_scope Configures wether a default scope is created that only returns published objects (default = false)

GUI support

The project includes helpers for a few CRUD runtime generators (such as ActiveAdmin, ActiveScaffold).

To use with ActiveAdmin, include the following in your form configuration:

f.inputs"Publication"dof.publicationsend

To use with ActiveScaffold, include the following in your form configuration:

TBD

Roadmap / TODO

Significant improvements

  • Support for publication workflow (aprovals)
  • Support for other conditions besides dates and boolean flag
  • Support for configurable publishing conditions
  • Support for users and groups (publish for just a given set of people)
  • Integration with fine-grained access control framework

Small improvements

  • Add ActiveScaffold support (and eventually RailsAdmin)
  • Add more tests
  • Implement down migrations
  • Add indexes
  • Default scopes
  • More configuration options

License

Copyright © 2013 Runtime Revolution, released under the MIT license.

githalytics.com alpha

About

Model publication handling for Rails

Resources

Stars

5 stars

Watchers

77 watching

Forks

Releases

Packages

Contributors

Languages