Cell

Cell provides tenancy and customer isolation for Rails. It tries to be a simpler and more thorough implementation of things like Apartment.

The core of Cell was written years ago for Rails 1.2, before Apartment was available, and has been developed inside an application ever since. We've aggressively moved it along with the ecosystem, and it still feels more modern than other implementations we've used. We're in the process of making it a more generalized gem. Things are a bit messy now.

Cell tries to hook into Rails at the highest level available (e.g., ActiveJob instead of a particular job adapter), except for one place: PostgreSQL. I think PostgreSQL is the only widely deployed database with the features required to make a reasonable implementation (namely: schemas, roles, row and column level security.)

Cell aggressively uses Ruby 2.3, PostgreSQL 9.6 and Rails 5. This means it's probably more appropriate for greenfield projects than bolting on to an existing application on an older stack.

Cell moves forward quickly: Don't expect to be able to hang back on an old version of Rails and get new features in Cell. We version accordingly not to break things, but we don't back-port to old Rubies, old PostgreSQLs, or old Rails versions.

The aforementioned Apartment gem looks like perfectly viable solution for projects with other constraints.

What it handles:

[x] ActiveRecord (including migrations and global tables) [ ] ActionController (An integration point for you) [ ] ActiveJob (we're transitioning a Sidekiq adapter to ActiveJob) [ ] ActionMailer (Your URIs will work) [ ] ActionView (Caching is automatically keyed on the Cell) [ ] Redis (optional, via redis-namespace) [x] Data Directories [x] Rake (e.g., tasks which run over each Cell)

The rest of this README will be updated as the code is extracted.

Installation

Add this line to your application's Gemfile:

gem 'cell'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cell

Tests

The application Cell was ripped out of had heavy test-coverage of the functionality Cell provides, but at the wrong level (e.g., our model, not the Cell behavior which this became). It's proven impossible to extract anything workable out of these into this gem, but we're working on starting from scratch.

Usage

FIXME: Write this!

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/metermd/cell.

License

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