Module: Cybele::Helpers::Devise

Included in:
AppBuilder
Defined in:
lib/cybele/helpers/devise.rb

Instance Method Summary collapse

Instance Method Details

#add_devise_authenticate_adminObject



30
31
32
33
34
# File 'lib/cybele/helpers/devise.rb', line 30

def add_devise_authenticate_admin
  inject_into_file 'app/controllers/hq/application_controller.rb',
                   template_content('devise/devise_authenticate_admin.rb.erb'),
                   after: 'class Hq::ApplicationController < ApplicationController'
end

#add_devise_protect_from_forgeryObject



36
37
38
39
40
# File 'lib/cybele/helpers/devise.rb', line 36

def add_devise_protect_from_forgery
  inject_into_file 'app/controllers/application_controller.rb',
                   template_content('devise/devise_protect_from_forgery.rb.erb'),
                   after: 'respond_to :html, :js, :json'
end

#add_devise_strong_parameterObject



42
43
44
45
46
47
48
49
50
# File 'lib/cybele/helpers/devise.rb', line 42

def add_devise_strong_parameter
  inject_into_file 'app/controllers/application_controller.rb',
                   template_content('devise/devise_strong_parameter.rb.erb'),
                   after: 'protect_from_forgery with: :exception, prepend: true'

  inject_into_file 'app/controllers/application_controller.rb',
                   template_content('devise/devise_before_action_strong_parameter.rb.erb'),
                   after: 'class ApplicationController < ActionController::Base'
end

#generate_devise_modelsObject



17
18
19
20
21
22
23
24
# File 'lib/cybele/helpers/devise.rb', line 17

def generate_devise_models
  generate 'devise User name:string surname:string is_active:boolean time_zone:string'
  generate 'devise Admin name:string surname:string is_active:boolean time_zone:string'
  configure_devise_locale_files
  devise_seeds
  configure_app_name(%w[db/seeds.rb])
  add_default_value_to_migrations
end

#generate_devise_settingsObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/cybele/helpers/devise.rb', line 6

def generate_devise_settings
  generate 'devise:install'
  gsub_file 'config/initializers/filter_parameter_logging.rb', /:password/,
            ':password, :password_confirmation'
  gsub_file 'config/initializers/devise.rb',
            /[email protected]/, "no-reply@#{app_name}.com"
  inject_into_file 'config/initializers/devise.rb', after: "# config.mailer = 'Devise::Mailer'\n" do
    template_content('devise/devise_mailer.rb.erb')
  end
end

#generate_devise_viewsObject



26
27
28
# File 'lib/cybele/helpers/devise.rb', line 26

def generate_devise_views
  directory 'devise/devise_views', 'app/views/devise'
end