Class: PagesCms::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- PagesCms::Generators::InstallGenerator
- Defined in:
- lib/generators/pages_cms/Install_generator.rb
Instance Method Summary collapse
- #add_filters ⇒ Object
- #add_helpers ⇒ Object
- #add_javascript ⇒ Object
- #add_route ⇒ Object
- #copy_migrations ⇒ Object
- #instructions ⇒ Object
- #run_migrations ⇒ Object
Instance Method Details
#add_filters ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 23 def add_filters inject_into_file 'app/controllers/application_controller.rb', after: "class ApplicationController < ActionController::Base\n" do "\n # added by PagesCMS. Fill out this helper to protect your controllers.\n def logged_in_admin\n # Do something if admin\n # is not logged in\n # ie: redirect_to root_path unless current_user.admin\n end\n RUBY\n end\nend\n" |
#add_helpers ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 36 def add_helpers inject_into_file 'app/helpers/application_helper.rb', after: "module ApplicationHelper\n" do "\n # added by PagesCMS. Fill out this helper to protect your views.\n def current_user_is_admin?\n true\n end\n RUBY\n end\nend\n" |
#add_javascript ⇒ Object
47 48 49 50 51 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 47 def add_javascript js_manifest = 'app/assets/javascripts/application.js' js_require_block = " //= require cocoon\n" insert_into_file js_manifest, js_require_block, :after => "//= require jquery\n" end |
#add_route ⇒ Object
19 20 21 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 19 def add_route route "mount PagesCms::Engine => '/'" end |
#copy_migrations ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 6 def copy_migrations puts ' ' puts ' Installing PagesCMS' puts ' -------------------' puts ' installing migrations' `rake pages_cms:install:migrations` end |
#instructions ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 53 def instructions puts ' ' puts ' To get hacking immediately it is recommended that you install bootstrap:' puts ' 1. Add: `gem "bootstrap-sass"` to your `Gemfile` ' puts ' 2. Add: `//= require bootstrap` to your `application.js` ' puts ' 3. Run: `$ bundle install` ' puts ' ' puts ' To get hacking the views and stylesheets: `$ rails generate pages_cms:views` ' puts ' ' puts ' To learn more: https://github.com/ColDog/PagesCMS' end |
#run_migrations ⇒ Object
14 15 16 17 |
# File 'lib/generators/pages_cms/Install_generator.rb', line 14 def run_migrations puts ' migrating database' `rake db:migrate` end |