Class: SimplePages::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SimplePages::Generators::InstallGenerator
- Defined in:
- lib/generators/simple_pages/install_generator.rb
Instance Method Summary collapse
- #append_user_mixin ⇒ Object
- #copy_config_file ⇒ Object
- #copy_libraries ⇒ Object
- #inject_application_controller ⇒ Object
- #mount_routes ⇒ Object
Instance Method Details
#append_user_mixin ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/simple_pages/install_generator.rb', line 33 def append_user_mixin user_model = "app/models/#{[: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 |
#copy_config_file ⇒ Object
13 14 15 |
# File 'lib/generators/simple_pages/install_generator.rb', line 13 def copy_config_file template 'simple_pages.rb', 'config/initializers/simple_pages.rb' end |
#copy_libraries ⇒ Object
8 9 10 11 |
# File 'lib/generators/simple_pages/install_generator.rb', line 8 def copy_libraries template 'devise_ext.rb', 'lib/devise_ext.rb' template 'cancan_ext.rb', 'lib/cancan_ext.rb' end |
#inject_application_controller ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/generators/simple_pages/install_generator.rb', line 23 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 |
#mount_routes ⇒ Object
17 18 19 20 21 |
# File 'lib/generators/simple_pages/install_generator.rb', line 17 def mount_routes insert_into_file 'config/routes.rb', after: "routes.draw do\n" do " mount SimplePages::Engine, at: '/'\n" end end |