8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/generators/autopilot/routes_generator.rb', line 8
def do_magic
puts "Setting up routes..."
@home = options['home']
template "controllers/pages_controller.rb", "app/controllers/pages_controller.rb"
template "views/pages/dash.html.erb", "app/views/pages/dash.html.erb"
copy_file "views/layouts/_nav.html.erb", "app/views/layouts/_nav.html.erb"
inject_into_file 'app/views/layouts/application.html.erb', after: "<body>\n" do <<-'RUBY'
<%= render 'layouts/nav' %>
RUBY
end
if @home
puts "Set up marketing home page..."
template "views/pages/home.html.erb", "app/views/pages/home.html.erb"
template "routes-with-home.rb", "config/routes.rb", force: true
inject_into_file 'app/views/layouts/_nav.html.erb', after: "<% else %>\n" do <<-'RUBY'
<%= link_to "Home", root_path %>
RUBY
end
else
template "routes-without-home.rb", "config/routes.rb", force: true
end
end
|