Class: Cancannible::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/cancannible/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

while methods have moved around this has been the implementation since ActiveRecord 3.0



28
29
30
31
32
33
34
35
# File 'lib/generators/cancannible/install_generator.rb', line 28

def self.next_migration_number(dirname)
  next_migration_number = current_migration_number(dirname) + 1
  if ActiveRecord::Base.timestamped_migrations
    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
  else
    "%.3d" % next_migration_number
  end
end

Instance Method Details

#create_initializer_fileObject



14
15
16
# File 'lib/generators/cancannible/install_generator.rb', line 14

def create_initializer_file
  template 'cancannible_initializer.rb', 'config/initializers/cancannible.rb'
end

#create_permission_migration_fileObject



18
19
20
# File 'lib/generators/cancannible/install_generator.rb', line 18

def create_permission_migration_file
  migration_template 'migration.rb', 'db/migrate/create_cancannible_permissions.rb'
end

#create_permission_model_fileObject



22
23
24
# File 'lib/generators/cancannible/install_generator.rb', line 22

def create_permission_model_file
  template 'permission.rb', 'app/models/permission.rb'
end