Class: Oath::Generators::PasswordResetGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Migration, Rails::Generators::Migration
Defined in:
lib/generators/oath/password_reset/password_reset_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Migration

#migration_version

Class Method Details

.next_migration_number(dir) ⇒ Object



39
40
41
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 39

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

Instance Method Details

#add_config_optionsObject



12
13
14
15
16
17
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 12

def add_config_options
  %w(development test production).each do |env|
    host = ask("What is the host to use for #{env}?")
    application(%{config.action_mailer.default_url_options = { :host => "#{host}" }}, env: env)
  end
end

#add_controllersObject



35
36
37
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 35

def add_controllers
  template 'app/controllers/password_resets_controller.rb', 'app/controllers/password_resets_controller.rb'
end

#add_mailersObject



31
32
33
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 31

def add_mailers
  template 'app/mailers/password_reset_mailer.rb', 'app/mailers/password_reset_mailer.rb'
end

#add_modelObject



43
44
45
46
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 43

def add_model
  template 'app/models/password_reset.rb', 'app/models/password_reset.rb'
  migration_template "db/migrate/create_password_resets.rb", "db/migrate/create_password_resets.rb", migration_version: migration_version
end

#add_routesObject



19
20
21
22
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 19

def add_routes
  route("resources :password_resets, only: [:new, :create]")
  route("resources :users, only: [:none] do\n    resources :password_resets, only: [:edit, :update]\n  end")
end

#add_viewsObject



24
25
26
27
28
29
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 24

def add_views
  copy_file 'app/views/password_resets/create.html.erb'
  copy_file 'app/views/password_resets/edit.html.erb'
  copy_file 'app/views/password_resets/new.html.erb'
  copy_file 'app/views/password_reset_mailer/change_password.html.erb'
end

#display_readmeObject



48
49
50
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 48

def display_readme
  readme 'password_reset_readme'
end