Class: Responders::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/responders/install_generator.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) copy_locale



30
31
32
# File 'lib/generators/responders/install_generator.rb', line 30

def copy_locale
  copy_file "../../responders/locales/en.yml", "config/locales/responders.en.yml"
end

- (Object) create_responder_file



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/responders/install_generator.rb', line 8

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
end
  RUBY
end

- (Object) update_application_controller



21
22
23
24
25
26
27
28
# File 'lib/generators/responders/install_generator.rb', line 21

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