Class: ActiveAuthentication::InstallGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



10
11
12
# File 'lib/generators/active_authentication/install/install_generator.rb', line 10

def self.next_migration_number(dirname)
  ActiveRecord::Migration.new.next_migration_number 0
end

Instance Method Details

#add_routeObject



26
27
28
# File 'lib/generators/active_authentication/install/install_generator.rb', line 26

def add_route
  route "active_authentication"
end

#copy_initializerObject



30
31
32
# File 'lib/generators/active_authentication/install/install_generator.rb', line 30

def copy_initializer
  template "initializer.rb", "config/initializers/active_authentication.rb"
end

#generate_migrationObject



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

def generate_migration
  migration_template "migration.rb", "db/migrate/create_users.rb", concerns: concerns, migration_version: migration_version, ip_column: ip_column
end

#generate_modelObject



14
15
16
17
18
19
20
# File 'lib/generators/active_authentication/install/install_generator.rb', line 14

def generate_model
  invoke "active_record:model", %w[User], migration: false, skip_collision_check: true

  if behavior == :invoke
    inject_into_class "app/models/user.rb", "User", "  authenticates_with #{concerns.map { ":#{_1}" }.join(", ")}\n"
  end
end