Displaying 1 result from an estimated 1 matches for "createandinitprivileges".
2006 Nov 09
2
help with join tables and has_and_belongs_to_many
...odel defs:
class User < ActiveRecord::Base
belongs_to :status
has_and_belongs_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.f...