Class: ActionSentinelGroup::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



17
18
19
# File 'lib/generators/action_sentinel_group/install_generator.rb', line 17

def self.next_migration_number(path)
  ActiveRecord::Generators::Base.next_migration_number(path)
end

Instance Method Details

#generateObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/action_sentinel_group/install_generator.rb', line 21

def generate
  model_file = File.join("app", "models", "#{user_model_name.underscore.singularize}.rb")

  if File.exist?(model_file) || revoke_process?
    create_models
    create_migrations
    inject_group_association_into_user_model(model_file)
    create_initializer
    invoke_action_sentinel_generator
  else
    logger.error("The file #{model_file} does not appear to exist")
  end
end