Class: Devise::Generators::UsersGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Extended by:
RailsAssist::UseMacro
Includes:
Cream::GeneratorHelper, DeviseUserGenerator::Helper, DeviseUserGenerator::RoutesHelper
Defined in:
lib/generators/devise/users/users_generator.rb

Instance Method Summary collapse

Methods included from DeviseUserGenerator::RoutesHelper

#default_signin_routes, #model_routes, #routes_configure!, #user_type_routes, #user_types_to_route

Methods included from DeviseUserGenerator::Helper

#admin_class_name, #create_user_model, #devise_strategies, #devise_users?, #has_admin_model?, #has_devise_user?, #has_user_model?, #inherit_model, #is_admin?, #remove_inheritance, #subclass, #superclass, #user_generator

Methods included from Cream::GeneratorHelper

#add_logger, #debug!, included, #info!, #logit!

Instance Method Details

#configure_devise_usersObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/generators/devise/users/users_generator.rb', line 33

def configure_devise_users      
	logit!
  debug! "Configure Devise Users"

  self.class.use_orm orm.to_sym

  devise_gems if gems?

  # create user model with devise strategies if user model doesn't already exist  
  devise_base_user if !has_user_model?

  # # if User model is NOT configured with devise strategy
  insert_devise_strategy user_class, :defaults if !has_devise_user? user_class

  # create role specific user inheriting from base User for each role
  user_types.flatten.each do |user_type|
    create_user(user_type) if !has_model?(user_type.as_filename)
  end
  
  routes_configure!
  
  registrations.each do |reg|
    if user_type? reg
      # create controller
      controller = "#{reg}::Registrations".camelcase
      rgen "controller #{controller} new"
      rgen "view #{controller} new"

      # make controller a devise controller
      replace_controller_inheritance controller.underscore, 'Devise::RegistrationsController'
    end
  end
end