Class: ActiveAdmin::Generators::DeviseGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- ActiveAdmin::Generators::DeviseGenerator
- Defined in:
- lib/generators/active_admin/devise/devise_generator.rb
Instance Method Summary collapse
- #add_default_user_to_migration ⇒ Object
- #create_admin_user ⇒ Object
- #install_devise ⇒ Object
- #remove_registerable_from_model ⇒ Object
- #set_namespace_for_path ⇒ Object
Instance Method Details
#add_default_user_to_migration ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/active_admin/devise/devise_generator.rb', line 37 def add_default_user_to_migration # Don't assume that we have a migration! devise_migrations = Dir["db/migrate/*_devise_create_#{table_name}.rb"] if devise_migrations.size > 0 inject_into_file Dir["db/migrate/*_devise_create_#{table_name}.rb"].first, "# Create a default user\n #{class_name}.create!(:email => '[email protected]', :password => 'password', :password_confirmation => 'password')\n\n ", :before => "add_index :#{table_name}, :email" end end |
#create_admin_user ⇒ Object
21 22 23 |
# File 'lib/generators/active_admin/devise/devise_generator.rb', line 21 def create_admin_user invoke "devise", [name] end |
#install_devise ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/active_admin/devise/devise_generator.rb', line 11 def install_devise require 'devise' if File.exists?(File.join(destination_root, "config", "initializers", "devise.rb")) log :generate, "No need to install devise, already done." else log :generate, "devise:install" invoke "devise:install" end end |
#remove_registerable_from_model ⇒ Object
25 26 27 28 29 30 |
# File 'lib/generators/active_admin/devise/devise_generator.rb', line 25 def remove_registerable_from_model unless [:registerable] model_file = File.join(destination_root, "app", "models", "#{file_path}.rb") gsub_file model_file, /\:registerable([.]*,)?/, "" end end |
#set_namespace_for_path ⇒ Object
32 33 34 35 |
# File 'lib/generators/active_admin/devise/devise_generator.rb', line 32 def set_namespace_for_path routes_file = File.join(destination_root, "config", "routes.rb") gsub_file routes_file, /devise_for :#{table_name}/, "devise_for :#{table_name}, ActiveAdmin::Devise.config" end |