class Responders::Generators::InstallGenerator

Public Instance Methods

copy_locale() click to toggle source
# 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() click to toggle source
# File lib/generators/responders/install_generator.rb, line 10
      def create_responder_file
        create_file "lib/application_responder.rb", <<~RUBY
          class ApplicationResponder < ActionController::Responder
            include Responders::FlashResponder
            include Responders::HttpCacheResponder

            # Redirects resources to the collection path (index action) instead
            # of the resource path (show action) for POST/PUT/DELETE requests.
            # include Responders::CollectionResponder

            # Configure default status codes for responding to errors and redirects.
            self.error_status = :unprocessable_entity
            self.redirect_status = :see_other
          end
        RUBY
      end
update_application() click to toggle source
# File lib/generators/responders/install_generator.rb, line 27
      def update_application
        inject_into_class "config/application.rb", "Application", <<-RUBY
    # Use the responders controller from the responders gem
    config.app_generators.scaffold_controller :responders_controller

        RUBY
      end
update_application_controller() click to toggle source
# 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", <<-RUBY
  self.responder = ApplicationResponder
  respond_to :html

        RUBY
      end