No commit activity in last 3 years
No release in over 3 years
Extends Gutentag with support for multitenancy.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0

Runtime

>= 0.7.0
 Project Readme

Gutentag::Multitenancy

This gem extends Gutentag with multitenancy support.

Gutentag's tags are available to every user of your application; this gem scopes the tags by tenant.

Installation

If you haven't installed Gutentag yet, install it now. You'll need to modify your Gemfile to install the latest version from HEAD:

gem 'gutentag', github: 'pat/gutentag', ref: '51bd8f2f37f21dc4ef84a87889db4f28aa3573e2'

Add gutentag_multitenancy to your Gemfile, and bundle install:

gem 'gutentag-multitenancy'

Now import and run the migration:

rake gutentag_multitenancy:install:migrations
rake db:migrate

Usage

Define a tenant_id method in each model which can have tags. In the following example each author has their own set of tags for articles:

class Article < ActiveRecord::Base
  belongs_to :author

  has_many_tags  # from Gutentag

  def tenant_id
    author.id
  end
end

To retrieve all the tags for a tenant, use the by_tenant_id scope:

Gutentag::Tag.by_tenant_id 42

To Do

  • Tests.

License

Copyright 2015 Andrew Stewart.

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