Class: Oath::Generators::PasswordResetGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Oath::Generators::PasswordResetGenerator
- Includes:
- Migration, Rails::Generators::Migration
- Defined in:
- lib/generators/oath/password_reset/password_reset_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_config_options ⇒ Object
- #add_controllers ⇒ Object
- #add_mailers ⇒ Object
- #add_model ⇒ Object
- #add_routes ⇒ Object
- #add_views ⇒ Object
- #display_readme ⇒ Object
Methods included from Migration
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_options ⇒ Object
12 13 14 15 16 17 |
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 12 def %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_controllers ⇒ Object
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_mailers ⇒ Object
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_model ⇒ Object
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_routes ⇒ Object
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_views ⇒ Object
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_readme ⇒ Object
48 49 50 |
# File 'lib/generators/oath/password_reset/password_reset_generator.rb', line 48 def display_readme readme 'password_reset_readme' end |