Sha256: 15ff08ef5acebd1a2667845cf04fa16437bfb813aab6634ffc1c40b3f30f7737

Contents?: true

Size: 1.61 KB

Versions: 27

Compression:

Stored size: 1.61 KB

Contents

require 'rails/generators'

module Pageflow
  module Generators
    class ActiveAdminInitializerGenerator < Rails::Generators::Base
      desc "Configure active admin utilitiy menu to contain profile link."

      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

      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

      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

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-17.0.3 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-17.0.2 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-17.0.1 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-17.0.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-16.2.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-16.1.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-16.0.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.8.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.7.1 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.7.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.6.1 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.6.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.5.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.4.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.3.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.2.2 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.2.1 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.2.0 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb
pageflow-15.1.2 lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb