23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/generators/flexible_admin/devise_generator.rb', line 23
def devise
append_file "Gemfile", "\n", :force => true
gem 'devise'
inside Rails.root do
run "bundle install"
end
unless File.exists?(Rails.root.join("config/initializers/devise.rb"))
say "Installing devise"
generate "devise:install"
end
unless File.exists?(Rails.root.join("app/models/admin_user.rb"))
generate "devise AdminUser"
template "user_sign_in.html.erb", "app/views/admin/admin_users/sessions/new.html.erb"
gsub_file 'config/routes.rb', "devise_for :admin_users", "devise_for :admin_users, :path_prefix => 'admin', :controllers => {:sessions => 'admin/admin_users/sessions' }"
template "admin_user_sessions_controller.rb", "app/controllers/admin/admin_users/sessions_controller.rb"
end
say "you now need to run 'rake db:migrate' to create the admin_users table", :blue
say "after that make your first admin_user in the console: AdminUser.create!(email: '[email protected]', password: 'password')", :blue
end
|