Ruby on Rails Newbie Question

software development

#1

Hi guys. I’m a fairly decent php programmer switching up to Ruby on Rails here on Dreamhost. I was wondering if there are any people on this board experienced with rails to answer this simple question for me:

Basically I bnought the new book for Rails ‘Agile Web Development…’ and I’ve been following the Hello world tutorial which went off without a hitch until I actually placed the ‘hello’ method into the controller file which is called ‘say’.

You might be able to see it by going here:
http://www.demo.jimjeffers.com:3000/say/hello

The WEBrick server doesn’t stay active indefinitely however so you might not be able to see the error in that case this is what happens:


SyntaxError in #

/usr/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:189:in `load’: app/controllers/say_controller.rb:1: syntax error
class SayController < ApplicationController

def hello
end
end
^
(eval):1:in `eat_path_to_controller’
script/server:48
Show framework trace
This error occured while loading the following files:
./script/…/config/…/app/controllers/say_controller.rb


All in all, I’m sure it’s something simple becuase I don’t know what I’m doing quite yet. The tutorial said you didn’t have to do anything pertaining to routing for this app and I followed all of the other instructions. I created the controller running ‘ruby script/generate Say’ in the shell then edited the controller file accordingly and created the say.rhtml file in the views/say directory.

The error I get sayins controller not set is what confuses me most. Anyone have any advice?


#2

Looks like you have one ‘end’ too many there.


#3

Nope this code runs on my local machine but not the dreamhost server what gives. The first end closes the method. The second end closes the controller class.


#4

Ah. To generate a controller use the command ‘script/generate controller controllername’. Also you shouldn’t have a say.rhtml file, but a hello.rhtml file inside the say directory under app\view.


#5

Actually, try writing the example through SSH, instead of uploading. See if that makes a difference.


#6

Thanks,
Ragg but no luck. I did use ‘script/generate controller Say’ to create the controller.

Also, I did name the view file hello.rhtml I made a mistake in my initial post. This code is working on my local machine. I don’t understand why it won’t work here :frowning:


#7

I fixed it! Just needed to add --without-gems to the rails command.