Class: KisoThemes::Generators::DeviseGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
HandlerSupport
Defined in:
lib/generators/kiso_themes/devise_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_layoutsObject



13
14
15
16
17
18
# File 'lib/generators/kiso_themes/devise_generator.rb', line 13

def copy_layouts
  abort "ERROR: Devise is installed, but the Devise installation generator does not appear to have been run. Please run `bin/rails g devise:install` and re-run this generator" and return unless devise? && devise_config_present?
  directory File.expand_path("../../../../app/views/devise/#{handler}", __FILE__), 'app/views/devise'
  copy_file "views/emails/_email_header.html.#{handler}", "app/views/emails/_email_header.html.#{handler}"
  copy_file "views/emails/_email_footer.html.#{handler}", "app/views/emails/_email_footer.html.#{handler}"
end

#inject_devise_initializer_configObject



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

def inject_devise_initializer_config
  abort "ERROR: Devise is installed, but the Devise installation generator does not appear to have been run. Please run `bin/rails g devise:install` and re-run this generator" and return unless devise? && devise_config_present?

  code = <<-INJECTEDCODE.strip_heredoc
    Rails.application.config.to_prepare do
      Devise::Mailer.layout "email"
      Devise::Mailer.send(:include, EmailTemplateHelper)\n
      Devise::Mailer.send(:helper, EmailTemplateHelper)\n
    end\n
  \n
  INJECTEDCODE

  inject_into_file( "config/initializers/devise.rb", code, :before => /^end/)
end