Class: Popolo::Generators::PopoloGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Popolo::Generators::PopoloGenerator
- Defined in:
- lib/generators/popolo_generator.rb
Overview
Run this generator once before using Popolo in your application.
Instance Method Summary collapse
- #add_rescue_from_block_to_application_controller ⇒ Object
- #add_routes ⇒ Object
- #add_ruby_version_to_gemfile ⇒ Object
- #show_readme ⇒ Object
Instance Method Details
#add_rescue_from_block_to_application_controller ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/popolo_generator.rb', line 17 def add_rescue_from_block_to_application_controller inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController' do <<-EOS rescue_from Mongoid::Errors::DocumentNotFound do |exception| respond_to do |format| format.html { render file: Rails.root.join('public', '404.html'), status: :not_found, layout: false } format.json { head :not_found } format.atom { head :not_found } end end EOS end end |
#add_routes ⇒ Object
13 14 15 |
# File 'lib/generators/popolo_generator.rb', line 13 def add_routes route "mount Popolo::Engine => '/'" end |
#add_ruby_version_to_gemfile ⇒ Object
31 32 33 |
# File 'lib/generators/popolo_generator.rb', line 31 def add_ruby_version_to_gemfile prepend_to_file 'Gemfile', "ruby '1.9.3'" end |
#show_readme ⇒ Object
35 36 37 |
# File 'lib/generators/popolo_generator.rb', line 35 def show_readme readme 'README' if behavior == :invoke end |