Class: Responders::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Responders::Generators::InstallGenerator
- Defined in:
- lib/generators/responders/install_generator.rb
Instance Method Summary collapse
- #copy_locale ⇒ Object
- #create_responder_file ⇒ Object
- #update_application ⇒ Object
- #update_application_controller ⇒ Object
Instance Method Details
#copy_locale ⇒ Object
44 45 46 |
# File 'lib/generators/responders/install_generator.rb', line 44 def copy_locale copy_file "../../responders/locales/en.yml", "config/locales/responders.en.yml" end |
#create_responder_file ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/responders/install_generator.rb', line 10 def create_responder_file create_file "lib/application_responder.rb", " class ApplicationResponder < ActionController::Responder\n include Responders::FlashResponder\n include Responders::HttpCacheResponder\n\n # Redirects resources to the collection path (index action) instead\n # of the resource path (show action) for POST/PUT/DELETE requests.\n # include Responders::CollectionResponder\n\n # Configure default status codes for responding to errors and redirects.\n self.error_status = :unprocessable_entity\n self.redirect_status = :see_other\n end\n RUBY\nend\n" |
#update_application ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/generators/responders/install_generator.rb', line 27 def update_application inject_into_class "config/application.rb", "Application", " # Use the responders controller from the responders gem\n config.app_generators.scaffold_controller :responders_controller\n\n RUBY\nend\n" |
#update_application_controller ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/generators/responders/install_generator.rb', line 35 def update_application_controller prepend_file "app/controllers/application_controller.rb", %{require "application_responder"\n\n} inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " self.responder = ApplicationResponder\n respond_to :html\n\n RUBY\nend\n" |