Sha256: 78f677cc43c8af7e1125067c5143b2d134435b41e6f9889cca6c1d3ca3bdc055
Contents?: true
Size: 917 Bytes
Versions: 17
Compression:
Stored size: 917 Bytes
Contents
class AddManyRolesStrategy < ActiveRecord::Migration class << self def up create_roles create_user_roles add_index :roles, :name, :unique => true # insert_roles end def down drop_roles drop_user_roles remove_index :roles, :name end protected def create_user_roles create_table :user_roles do |t| t.integer :user_id t.integer :role_id t.timestamps end end def drop_user_roles drop_table :user_roles end def create_roles create_table :roles do |t| t.string :name t.timestamps end end def drop_roles drop_table :roles end def insert_roles roles_to_add.each do |role| begin Role.create(:name => "#{role}") rescue end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems