Sha256: 19af06e8defe1d424d598773fdd156e780b338bc669519f21ab6a4b2f4e8d5a9

Contents?: true

Size: 528 Bytes

Versions: 11

Compression:

Stored size: 528 Bytes

Contents

h1. Alternative Multi Roles setup

<pre>
  class UsersHaveAndBelongToManyRoles < ActiveRecord::Migration
    def self.up
      create_table :roles_users, :id => false do |t|
        t.references :role, :user
      end
    end

    def self.down
      drop_table :roles_users
    end
  end  
</pre>

And your models look like this:

<pre>
  # User Model
  class User < ActiveRecord::Base
    has_and_belongs_to_many :roles
  ....
  # Role model
  class Role < ActiveRecord::Base
    has_and_belongs_to_many :users
  end  
</pre>

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
roles_active_record-0.5.1 NOTES.textile
roles_active_record-0.5.0 NOTES.textile
roles_active_record-0.4.9 NOTES.textile
roles_active_record-0.4.8 NOTES.textile
roles_active_record-0.4.7 NOTES.textile
roles_active_record-0.4.6.4 NOTES.textile
roles_active_record-0.4.6.3 NOTES.textile
roles_active_record-0.4.6.2 NOTES.textile
roles_active_record-0.4.6.1 NOTES.textile
roles_active_record-0.4.6 NOTES.textile
roles_active_record-0.4.5 NOTES.textile