Sha256: 41e7cfc5d8e351e52651828fb53534081f424e89e7d9a57c48b4c2269b69b2d0
Contents?: true
Size: 1.45 KB
Versions: 7
Compression:
Stored size: 1.45 KB
Contents
module SimplePages module Generators class InstallGenerator < Rails::Generators::Base desc 'Copies SimplePages configuration file and libraries.' source_root File.expand_path('../templates', __FILE__) class_option :user_model, default: 'user', desc: 'User model used in application.' def copy_libraries template 'devise_ext.rb', 'lib/devise_ext.rb' template 'cancan_ext.rb', 'lib/cancan_ext.rb' end def copy_config_file template 'simple_pages.rb', 'config/initializers/simple_pages.rb' end def mount_routes insert_into_file 'config/routes.rb', after: "routes.draw do\n" do " mount SimplePages::Engine, at: '/'\n" end end def inject_application_controller insert_into_file 'app/controllers/application_controller.rb', after: /class ApplicationController < ActionController::Base\n/ do <<-CODE include DeviseExt include CanCanExt include SimplePages::Controllers::PageLayoutAt CODE end end def append_user_mixin user_model = "app/models/#{options[:user_model].downcase}.rb" unless File.exist? user_model raise 'You need to specify an user model. Try --user-model option' end insert_into_file user_model, before: /^end\n/ do <<-CODE def name email end include SimplePages::Models::PageAuthor CODE end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems