Class: TwoStep::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



23
24
25
# File 'lib/generators/two_step/install_generator.rb', line 23

def create_initializer
  template "initializer.rb.erb", "config/initializers/two_step.rb"
end

#create_migration_fileObject



15
16
17
18
19
20
21
# File 'lib/generators/two_step/install_generator.rb', line 15

def create_migration_file
  migration_template(
    "migration.rb.erb",
    "db/migrate/add_two_step_to_#{table_name}.rb",
    migration_version: migration_version
  )
end

#show_readmeObject



27
28
29
30
31
# File 'lib/generators/two_step/install_generator.rb', line 27

def show_readme
  say "Add to your #{model} model:", :green
  say "  include TwoStep::Models::Authenticatable"
  say "  encrypts :otp_secret  # recommended (Rails 7+)"
end