Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 29 lines (24 sloc) 0.528 kb
23eb6d1 @kristianmandrup added NOTES on how to setup alternative multi roles model using habtm
authored
1 h1. Alternative Multi Roles setup
2
3 <pre>
4 class UsersHaveAndBelongToManyRoles < ActiveRecord::Migration
5 def self.up
6 create_table :roles_users, :id => false do |t|
7 t.references :role, :user
8 end
9 end
10
11 def self.down
12 drop_table :roles_users
13 end
14 end
15 </pre>
16
17 And your models look like this:
18
19 <pre>
20 # User Model
21 class User < ActiveRecord::Base
22 has_and_belongs_to_many :roles
23 ....
24 # Role model
25 class Role < ActiveRecord::Base
26 has_and_belongs_to_many :users
27 end
28 </pre>
Something went wrong with that request. Please try again.