My links aren't working for my ruby on rails site. When I click the link the site stays on the same page. I'm following code from a book called: "RailsSpace: Building a social networking site with ruby on rails" By Michael Hartl. The book is available free for download you can follow the code for yourself, its on pages 55-56 starting under the title "adding navigation". Here is a link to the ebook.
Thanks for your help.
I tried googling the "link_to" function and changing the format, all it did was generate more errors please help.
Here is the code from my app/views/layout/site.html.erb file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><%= @title %></title>
<%= stylesheet_link_tag "site" %>
</head>
<body>
<div id="whole_page">
<div id="header">RailsSpace</div>
<div id="nav">
<%= link_to_unless_current "Home", :action => "index" %> |
<%= link_to "About Us" , :action => "help" %> |
<%= link_to_unless_current "Help", :action => "help" %>
<div style="background-color:white">
<h1>Welcome to RailSpace!</h1>
<p>This is going to be the best site ever!</p>
</div>
</div>
<div id="content">
<%= @content_for_layout %>
</div>
</div>
</body>
</html>
Here is the code for my app/controllers/site_controller.rb file:
class SiteController < ApplicationController
def index
@title = "Welcome to RailsSpace!"
end
def about
@title = "About RailsSpace"
@header = "Hello"
end
def help
@title = "RailsSpace Help"
end
end
Here is the code for my config/routes.rb file:
Rails.application.routes.draw do
get 'site/index'
get '/site/about'
get 'site/help'
root 'site#index'
// Here is the output from the console when I click on a link as requested:
Started GET "/site/about" for ::1 at 2019-10-01 15:28:48 -0700
Processing by SiteController#about as HTML
Rendering site/about.html.erb within layouts/site
Rendered site/about.html.erb within layouts/site (Duration: 0.0ms |
Allocations: 5)
Completed 200 OK in 7ms (Views: 6.8ms | ActiveRecord: 0.0ms |
Allocations: 2921)
Thanks for all your help
When I click on the links in my navbar the site stays on the same page. Please help.