Sha256: a40d9cbf14a6e5915672796ff4c41d644edbf2d4f5e8a4b1d27cc8536a9d4998

Contents?: true

Size: 1010 Bytes

Versions: 3

Compression:

Stored size: 1010 Bytes

Contents

require 'rails/generators/active_record'

module Adminos::Generators
  class ProfileGenerator < Rails::Generators::Base
    include ActiveRecord::Generators::Migration

    desc 'Set up admin profile page'
    source_root File.expand_path '../../templates/profile', __FILE__

    def auto
      directory 'auto', '.', mode: :preserve
    end

    def route
      insert_into_file "config/routes.rb", after: "resource  :settings, only: [:edit, :update]\n" do
        <<~ROUT.indent(6)
          resource  :profile, only: [:edit, :update]
        ROUT
      end
    end

    def sidebar_link
      insert_into_file "app/views/shared/admin/_sidebar.slim", before: "\n        = top_menu_item active: 'admin/settings#' do" do
        <<~SLIM.indent(8)

          = top_menu_item active: 'admin/profiles#' do
            = link_to edit_admin_profile_path, class: 'nav__link' do
              span.link.link--settings
                = t('admin.profile.actions.index.header')
        SLIM
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adminos-1.0.0.pre.rc.5 lib/generators/adminos/profile_generator.rb
adminos-1.0.0.pre.rc.4 lib/generators/adminos/profile_generator.rb
adminos-1.0.0.pre.rc.3 lib/generators/adminos/profile_generator.rb