Ruby on Rails: Hello World

ruby, ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.2

Solution

Wow. I actually just stumbled upon the actual root problem:

I was creating my project within a folder that had a bracket in the name -- that is, I was running "rails new web" from within "/coding/workspace/[My] Toolbag".

Tonight I happened to try once more in "/coding/workspace", and it finally worked. So then I tested "rails new web" from within the following locations to flesh out my suspicion:

/coding/workspace/test1
/coding/workspace/test 2
/coding/workspace/test [3]
/coding/workspace/test [4
/coding/workspace/test ]5
/coding/workspace/test [6/subfolder

Suspicion confirmed. Rails projects within folders 3,4,6 demonstrate the problem I described in this question, while rails projects within folders 1,2,5 work just fine.

Specifically, the problem is an open bracket anywhere in the path: "["

I'm using Linux Mint. The problem might apply even more broadly, though I haven't yet attempted to repro on other distros, Windows, or Mac.

With many thanks to Brett Sanders for all of his repeated assistance and confirmation that I my approach should have been correct, I'm submitting this answer and marking this one as correct, in case anyone else encounters the same issue.

Problem

Long-time Java dev, first-time Ruby dev. Trying to reach the "hello world" step with a Rails app, and having difficulty. I'm positive that I'm missing something basic here. That being said, none of StackOverflow's "Questions with similar titles" nor Google's "ruby rails hello world" hits (or variants thereof) have clarified what I'm missing. I've got ruby (v1.9.3p194), gem (1.8.23) and rails (3.2.3) installed via RVM. I generated a controller using: ``` rails generate controller common ``` In the default "config/routes.rb", I have the following two routing attempts: ``` Web::Application.routes.draw do root :to => "common#index" match ':controller(/:action(/:id))(.:format)' end ``` When I initially ran "rails server" and loaded "http://localhost:3000/common" in my browser, I saw the following: ``` Unknown action The action 'index' could not be found for CommonController ``` I learned this is because "index" was not defined for my common controller, so I've edited "app/controllers/common_controller.rb" to contain the following: ``` class CommonController < ApplicationController def index end end ``` I now see the following at "http://localhost:3000/common" in my browser: ``` Template is missing Missing template common/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/coding/workspace/[My] Toolbag/web/app/views" ``` I see the same thing at root, which makes sense. From what I've found, this is clearly due to not having anything rendering in my controller, so I believe it should instead be checking for something at "app/views/common/index.html.erb" -- however, I do have a file there, containing the following: ``` <h1>Hello World</h1> ``` I've also tried renaming "index.html.erb" to "_index.html.erb", "index.html", and "index", all based on Googling variants of the console error "ActionView::Missing Template" and the similar browser output above. Many of the Google results contain snippets of suggestions, but without clear guidance on which file(s) to edit with said suggestions, or else with repeats of the steps that I've already taken above. If anyone could advise what I'm missing, I'd appreciate it. PS: I'm running as super-user, with "root:root" ownership of all files referenced here. Might rails be intended to be run as a regular user? Doesn't seem like that would let me get quite this far if it was the case, though.

Original source