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.