Sha256: 78d39fe37e036ce49c689fab92e9f71620812a81c6fe671b8b60191d30cdc85d
Contents?: true
Size: 1010 Bytes
Versions: 15
Compression:
Stored size: 1010 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 :<%= table_name.singularize %>_roles do |t| t.integer :<%= table_name.singularize %>_id t.integer :role_id t.timestamps end end def drop_user_roles drop_table :<%= table_name.singularize %>_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
15 entries across 15 versions & 1 rubygems