Class: Scrapbook::RoutesGenerator

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

Overview

A generator to create a new scrapbook with either the default (scrapbook) or specified name. (Using the default options for the URL path and folder root.)

Instance Method Summary collapse

Instance Method Details

#routesObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/scrapbook/routes_generator.rb', line 11

def routes
  # TODO: Investigate using a Rubocop rule to determine using single or double auotes.

  inject_into_file('config/routes.rb', after: "Rails.application.routes.draw do\n") do
    "  extend Scrapbook::Routing\n"
  end

  inject_into_file('config/routes.rb', after: "extend Scrapbook::Routing\n") do
    "\n  scrapbook('#{name}') if Rails.env.development?\n"
  end
end