Sha256: d0f96631cacdeab66a2b16f977520250349e852cf9928c35faab7df513e84af6
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
class CreateRightsAndRoles < ActiveRecord::Migration def self.up create_table :role_assignments do |t| t.column :role_id, :integer t.column :user_id, :integer end create_table :roles do |t| t.column :name, :string t.column :description, :string end create_table :permission_groups do |t| t.column :right_id, :integer, :null => false t.column :role_id, :integer, :null => false end create_table :rights do |t| t.column :name, :string t.column :controller_name, :string t.column :actions, :string t.column :hours, :float, :null => false end end def self.down drop_table :role_assignments drop_table :roles drop_table :permission_groups drop_table :rights end end class Right < ActiveRecord::Base has_many :permission_groups, :dependent => :destroy has_many :roles, :through => :permission_groups end class Role < ActiveRecord::Base has_many :permission_groups, :dependent => :destroy has_many :rights, :through => :permission_groups has_many :role_assignments, :dependent => :destroy def has_right?(right) rights.include? right end end class PermissionGroup < ActiveRecord::Base belongs_to :right belongs_to :role end class RoleAssignment < ActiveRecord::Base belongs_to :user belongs_to :role end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activerecord-jdbc-adapter-1.3.0.beta2 | test/models/rights_and_roles.rb |
activerecord-jdbc-adapter-1.3.0.beta1 | test/models/rights_and_roles.rb |