0.01
No commit activity in last 3 years
No release in over 3 years
Camaraderie takes away the pain of managing membership stuff between users and organizations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
~> 2.14

Runtime

 Project Readme

Camaraderie

Gem Version Code Climate Build Status

Camaraderie takes away the pain of managing membership stuff between users and organizations.

Installation

Add this line to your application's Gemfile:

gem 'camaraderie'

Then run the task to generate the migration:

$ rails generate camaraderie:install

Usage

First, you have to configure which type of memberships you want. Usually, you’d do this in ./config/initializers/camaraderie.rb:

Camaraderie.configure do |config|
  # The different types of memberships (defaults to `['admin']`)
  config.membership_types = %w(admin moderator member)

  # The class name of the organization model (defaults to `'Organization'`)
  config.organization_class = 'Company'

  # The class name of the user model (defaults to `'User'`)
  config.user_class = 'Employee'
end

Then, you can include the two provided modules into your User, Organization and Membership models:

class User < ActiveRecord::Base
  acts_as_user
end

class Organization < ActiveRecord::Base
  acts_as_organization
end

class Membership < ActiveRecord::Base
  acts_as_membership
end

You’re pretty much done after that. You’re now able to do this:

user = User.find(1)
organization = Organization.find(1)

# Add the user as an admin
organization.admins.create(user: user)

# Add the user as a regular member
organization.members.create(user: user)

# Check whether the user is an admin
user.admin_of?(organization)
# => true

# List all the admins for the organization
organization.admin_users
# => #<ActiveRecord::Relation [<User id=1>]>

License

Camaraderie is © 2013 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.