Class: FixturesGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_coffeeObject



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_controllerObject



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_sassObject



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_viewsObject



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_routesObject



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