Displaying 1 result from an estimated 1 matches for "privileges_us".
Did you mean:
privileges_
2006 Nov 09
2
help with join tables and has_and_belongs_to_many
..._to_many :privileges
end
class Privilege < ActiveRecord::Base
has_and_belongs_to_many :users
end
Now I have a migration script to create the join table and populate a
few users with some privileges...
class CreateAndInitPrivileges < ActiveRecord::Migration
def self.up
create_table :privileges_users do |t|
t.column :user_id, :integer, :null => false
t.column :privilege_id, :integer, :null =>false
end
admin_priv = Privilege.find_by_name(''admin'')
user_priv = Privilege.find_by_name(''user'')
admin_user = User.find_by_email(...