Class: FixturesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- FixturesGenerator
- Defined in:
- lib/generators/fixtures/fixtures_generator.rb
Instance Method Summary collapse
- #create_coffee ⇒ Object
- #create_controller ⇒ Object
- #create_sass ⇒ Object
- #create_views ⇒ Object
- #modify_routes ⇒ Object
Instance Method Details
#create_coffee ⇒ Object
19 20 21 22 23 |
# File 'lib/generators/fixtures/fixtures_generator.rb', line 19 def create_coffee create_file "app/assets/javascripts/relevance_rails.js.coffee", <<-STR console.log 'Hello from Relevance, Inc!' STR end |
#create_controller ⇒ Object
2 3 4 5 6 7 |
# File 'lib/generators/fixtures/fixtures_generator.rb', line 2 def create_controller create_file "app/controllers/relevance_rails_controller.rb", <<-STR class RelevanceRailsController < ApplicationController end STR end |
#create_sass ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/fixtures/fixtures_generator.rb', line 25 def create_sass create_file "app/assets/stylesheets/relevance_rails.css.scss", <<-STR $background: blue; h1.relevance { background-color: $background; } STR end |
#create_views ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/generators/fixtures/fixtures_generator.rb', line 9 def create_views create_file "app/views/relevance_rails/index.html.haml", <<-STR %h1 WELCOME HOME STR create_file "app/views/relevance_rails/db.html.haml", <<-STR - results = ActiveRecord::Base.connection.select_all("select 4200+42 as advanced_math") %h1.advanced_math= results.first["advanced_math"] STR end |
#modify_routes ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/fixtures/fixtures_generator.rb', line 35 def modify_routes insert_into_file "config/routes.rb", :after => "::Application.routes.draw do" do <<-STR # Required to test relevance_rails gem. match '/relevance_rails' => 'relevance_rails#index' match '/relevance_rails/db' => 'relevance_rails#db' STR end end |