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

#copy_localeObject



38
39
40
# File 'lib/generators/responders/install_generator.rb', line 38

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

#create_responder_fileObject



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", "class ApplicationResponder < ActionController::Responder\ninclude Responders::FlashResponder\ninclude 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\nend\n"
end

#update_applicationObject



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

def update_application
  inject_into_class "config/application.rb", "Application", "# Use the responders controller from the responders gem\nconfig.app_generators.scaffold_controller :responders_controller\n\n"
end

#update_application_controllerObject



29
30
31
32
33
34
35
36
# File 'lib/generators/responders/install_generator.rb', line 29

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\nrespond_to :html\n\n"
end