views:

76

answers:

2

I am brand new to Ruby on Rails and I have been trying to get a simple default route set up and working. When I try to run my application I get a blank result (if I do a view source, there is nothing there).

Here are the relevant files (not sure if I am missing something that would be useful).

app/config/routes.rb

Blog::Application.routes.draw do
  root :to => "home#index"
end

app/views/home/index.html.erb

<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>

app/controllers/home_controller.rb

class HomeController < ApplicationController
  def index
  end
end

app/views/layouts/application.html.erb

<!DOCTYPE html>
<html>
<head>
  <title>Benji</title>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
</head>
<body>

<%= yield %>

</body>
</html>

When I try to run my application, I go to http://localhost:3000 and nothing shows up. If I do a view source, it is empty.

If do rake routes this is the result:

JESSE-GAVINs-MacBook-Pro-17:benji jesse$ rake routes
(in /Users/jesse/Dev/benji)
root  /(.:format) {:action=>"index", :controller=>"home"}
JESSE-GAVINs-MacBook-Pro-17:benji jesse$

In my development.log file I see this:

Started GET "/" for 127.0.0.1 at Tue Sep 07 10:44:10 -0500 2010
  Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (2.8ms)
Completed 200 OK in 15ms (Views: 14.7ms | ActiveRecord: 0.0ms)

What could be the issue? How do I go about solving this?

A: 

Solved (sort of...)

It works just fine when I started the rails server on a different port.

It was my understanding that I didn't need to restart the server in order for it to detect changes in the code.

Sorry about the waste of time, I just didn't know which tree I needed to bark up. I learned some things along the way.

jessegavin
When you are working in development mode, in most cases you don't need to restart your server.
klew
A: 

As you're playing with Routes, you absolutely need to restart the server. I don't know if this is part of the problem, but most (all?) things under config/ need the server to be restarted to take effect, particularly routes and environment

Omri
You don't need to restart server after changing routes
klew
Really? Interesting. I thought everything under config needed a restart. I know if you're using RESTful routes, you can create a new action and it'll automatically get translated into a route, but I didn't know you can map a new route without restarting. Good to know
Omri