Class: Pageflow::Generators::ActiveAdminInitializerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb

Instance Method Summary collapse

Instance Method Details

#configure_active_adminObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb', line 14

def configure_active_admin
  inject_into_file 'config/initializers/active_admin.rb', after: "ActiveAdmin.setup do |config|\n" do
    <<-RUBY
  Pageflow.active_admin_settings(config)

  config.namespace :admin do |admin|
    # Place a user user profile button next to the sign out link.
    admin.build_menu :utility_navigation do |menu|
menu.add(:label => proc { display_name current_active_admin_user },
         :id => 'current_user',
         :if => proc { current_active_admin_user? },
         :url => '/admin/users/me')
admin.add_logout_button_to_menu(menu)
    end
  end
RUBY
  end
end

#configure_active_admin_load_pathObject



8
9
10
11
12
# File 'lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb', line 8

def configure_active_admin_load_path
  prepend_to_file 'config/initializers/active_admin.rb' do
    "ActiveAdmin.application.load_paths += [Pageflow.active_admin_load_path]\n\n"
  end
end

#use_can_canObject



43
44
45
46
47
# File 'lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb', line 43

def use_can_can
  gsub_file('config/initializers/active_admin.rb',
            '# config.authorization_adapter =',
            'config.authorization_adapter =')
end

#use_deviseObject



33
34
35
36
37
38
39
40
41
# File 'lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb', line 33

def use_devise
  gsub_file('config/initializers/active_admin.rb',
            '# config.current_user_method =',
            'config.current_user_method =')

  gsub_file('config/initializers/active_admin.rb',
            '# config.authentication_method =',
            'config.authentication_method =')
end