Sha256: b57f7bb83cf4dcce2bfebe4de0dc7b80cea5ad8c204a35475e333d3fd8d10e87

Contents?: true

Size: 700 Bytes

Versions: 11

Compression:

Stored size: 700 Bytes

Contents

class AddManyRolesStrategy < ActiveRecord::Migration
  class << self

    def up          
      create_roles
      create_user_roles
    end

    def down      
      drop_roles
      drop_user_roles
    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
roles_active_record-0.3.4 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.3.3 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.3.2 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.3.1 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.2.5 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.2.4 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.2.3 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.2.2 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.2.1 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.2.0 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb
roles_active_record-0.1.0 lib/generators/active_record/roles_migration/templates/add_many_roles_strategy.erb