Class: Dynamite::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/dynamite.rb

Instance Method Summary collapse

Instance Method Details

#do_installationObject

Every public method gets executed - which is a bit wierd! the ‘do_installation’ method could have been called ‘fundito’, and would have worked just the same check out railscasts.com/episodes/218-making-generators-in-rails-3



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dynamite.rb', line 15

def do_installation

  copy_file "db/migrate/install_dynamite.rb", "db/migrate/#{Time.now.getutc.strftime('%Y%m%d%H%M%S')}_install_dynamite.rb"
  
  directory "app/models", "app/models"
  directory "app/controllers", "app/controllers"
  directory "app/views", "app/views"

  route "resources :forms"
  route "resources :form_submissions"
  
  directory "app/assets/stylesheets/", "app/assets/stylesheets"

  gsub_file 'app/assets/javascripts/application.js', /\Z/m do ||
    "\n//= require dynamite"
  end

  
end