Class: CommonwealthVlrEngine::RoutesGenerator

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

Instance Method Summary collapse

Instance Method Details

#inject_vlr_routesObject

Add CommonwealthVlrEngine to the routes



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/commonwealth_vlr_engine/routes_generator.rb', line 16

def inject_vlr_routes
  unless IO.read("config/routes.rb").include?('CommonwealthVlrEngine::Engine')
    marker = 'Rails.application.routes.draw do'
    insert_into_file "config/routes.rb", :after => marker do
      %q{

  root :to => 'pages#home'

  # routes for CommonwealthVlrEngine
  mount CommonwealthVlrEngine::Engine => '/commonwealth-vlr-engine'

  # user authentication
  devise_for :users, :controllers => {:omniauth_callbacks => "users/omniauth_callbacks", :registrations => "users/registrations", :sessions => "users/sessions"}
}
    end

    bl_root_marker = 'root to: "catalog#index"'
    gsub_file("config/routes.rb", bl_root_marker, "")

  end
end