First day using rails


#1

Hi - this is my first day with Ruby on Rails.
I’m starting out by working through the Helloworld (Hello Ruby) example
program printed up in “Agile Web D. with Rails.”

My steps are as in the text:

  1. ruby script/generate controller Say
  2. edit the proper file and add the hello method
  3. fire up the browser using address http://localhost:3000
  4. fire up the browser again using the address
    http://localhost:3000/say/hello/

steps 1 and 2 are easy
step 3 produces a nice “Rails: Welcome Aboard” page
Getting started Here’s how to get rolling:

  1. Create your databases and edit config/database.yml

Rails needs to know your login and password.
2. Use script/generate to create your models and controllers

To see all available options, run it without parameters.
3. Set up a default route and remove or rename this file

Routes are setup in config/routes.rb.

step 4 produces nothing

I’m at a loss. I thought that I did what was needed.
Yet the web browser screen comes back empty.

Note that I didn’t setup a database nor setup a default route.
If that is perhaps the issue then that’s where I’ll need to start.

Sincerely,
Barney T.


#2

hi you are on the way !

just be sure u have a say_controller.rb in app/controllers with a class
SayController < ApplicationController
and u have de def hello in that file with render_text are a .rhtml file
behind.

you dont have to set up route , that’s the default setup.
try to create the rail app with rails myfoolishapp
then just save your say_controller.rb in !


#3

On Dec 22, 2005, at 12:36 PM, Barney T. wrote:

  1. ruby script/generate controller Say
  2. edit the proper file and add the hello method

What’s in the hello method?

If there’s very little (nothing?), you’ll need to add a view as well.


– Tom M.


#4

On 12/22/05, Barney T. removed_email_address@domain.invalid wrote:

http://localhost:3000/say/hello/
Rails needs to know your login and password.

I’m at a loss. I thought that I did what was needed.
Yet the web browser screen comes back empty.

Note that I didn’t setup a database nor setup a default route.
If that is perhaps the issue then that’s where I’ll need to start.

Sincerely,
Barney T.

I assume your expecting the “Template is missing” error as shown on pg.
32?

Do you have a file “./app/views/say/hello.rhtml”.

For the error to occur, this file has to be missing.

If the file exists, but is empty you will get a blank page.

When you put in the code at the top of pg 33, you should get your
first static page.

FYI: I’m only about 20 pages ahead of you, but I didn’t have any
issues with the above.

HTH
Greg

Greg F.
The Norcross Group
Forensics for the 21st Century


#5

just be sure u have a say_controller.rb in app/controllers with a class
SayController < ApplicationController
and u have de def hello in that file with render_text are a .rhtml file
behind.

   I have each of those pieces in place.

try to create the rail app with rails myfoolishapp
then just save your say_controller.rb in !

   I have my previously saved say_controller in app/controllers.
   It looks like the one on page 31 with the .rhtml file on p33 

behind.

Now that those preliminary setup steps are completed, comes the time to
see
what the system will reply based on my setup.

I type

rails script/controller  (to run WEBrick)
mozilla http://localhost:3000/say/hello/

I expect
“Hello from Rails” (as on p 33)
I actually see
(a blank page).

Typing
mozilla http://localhost:3000/say/myfoolishapp/
produces
(also a blank page).


#6

just be sure u have a say_controller.rb in app/controllers with a class
SayController < ApplicationController
and u have de def hello in that file with render_text are a .rhtml file
behind.

    I have setup exactly those pieces (controller and view).

cat app/controllers/say_controller.rb
class SayController < ApplicationController

def hello
end
end

b@yx:~/src/work/demo$ cat app/views/say/hello.rhtml

Hello, Rails!

Hello from Rails!

  however, my program doesn't produce the expected output--it 

doesn’t
produce any output.
After starting WEBrick, mozilla http://localhost:3000/ works fines (it
produces a default greeting).
But mozilla http://localhost:3000/say/hello/ doesn’t (it produces a
blank
page). If you have any suggestions or tests that I can run–let me
know.
Thanks in advance, Barney T…


#7

On 12/23/05, Barney T. removed_email_address@domain.invalid wrote:

class SayController < ApplicationController

But mozilla http://localhost:3000/say/hello/ doesn’t (it
produces a blank page). If you have any suggestions or tests that I can
run–let me know.
Thanks in advance, Barney T…

Did you start WEBrick from your top folder? (ie. the folder that
contains app, script, public, etc.)

Greg

Greg F.
The Norcross Group
Forensics for the 21st Century


#8

Please note that the rails literature gets updated frequently.
The documentation and latest source versions often contain fixes to
recent issues.
The issue here was that the documentation suggested using an older
version of ruby.
And it just so happened that the newest stable version of ruby was the
version that was really needed.

Good luck!


#9

ok so,

you make :
mkdir railswork
cd railswork
rails helloapp
cd helloapp
ruby script/generate controller say (add a hello method)
edit the app/view/say/hello.rhtml
the in helloapp
ruby script/server

and it work, i have just done it ! (see in .zip)

that’s harder with mysql .

Barney T. wrote:

Hello, Rails! After starting WEBrick, mozilla http://localhost:3000/ works fines (it produces a default greeting). But mozilla http://localhost:3000/say/hello/ doesn't (it produces a blank page). If you have any suggestions or tests that I can run--let me know

“Ce message et toutes les pièces jointes sont des informations
strictement confidentielles et réservées au(x) destinataire(s). Ce
courriel n’a pas de valeur contractuelle et son contenu ne constitue ni
une acceptation, ni un engagement de la part de l’auteur et des sociétés
du groupe Serveur et Artprice, sauf dans le cas où cela aurait été prévu
avec le destinataire par un accord écrit. Le contenu de ce message et
les pièces jointes ne peuvent constituer une preuve au sens de l’article
1316-1 du Code Civil. L.auteur et les sociétés du groupe Serveur et
Artprice déclinent toute responsabilité au titre de ce courriel s’il a
été altéré, déformé, falsifié ou indûment utilisé par des tiers ou
encore s’il a causé tout dommage ou perte de toute nature. Si vous
n’êtes pas le bon destinataire, merci de nous contacter et de ne pas le
divulguer.”

“This message including any attachments are confidential and privileged
material intended solely for the addressees. Its contents do not
constitute a commitment by groupe Serveur sas and Artprice SA, except
when provided for in a written agreement with the addressees. The
contents of this message cannot constitute neither the proof nor the
acceptance of any agreement as per article 1316-1 of the French civil
code.
Groupe Serveur sas and Artprice SA shall not be rendered liable in any
manner whatsoever for the delay and/or loss in transit of this message,
for corruption, alteration, falsification, misuse or fraudulent use
(which may be made) of this message. If you receive this message in
error, please delete it and immediately notify the sender. If the reader
of this message is not the intended recipient, you are hereby notified
that any unauthorized use, copying or dissemination is prohibited.”


#10

Please note that the rails literature gets updated frequently.
The documentation and latest source versions often contain fixes to
recent issues.
The issue here was that the documentation suggested using an older
version of ruby.
And it just so happened that the newest stable version of ruby was the
version that was really needed.

Good luck!


#11

On Dec 31, 2005, at 8:46 AM, Barney T. wrote:

b@yx:~/src/work/demo$ cat app/views/say/hello.rhtml

know.
I’ve noticed that with Mozilla browsers, they will sometimes show a
blank page when Webrick serves up an error 500. I noticed this happen
usually when Rails is having difficulties connecting to a database,
or config/database.yaml is configured incorrectly. Looking at log/
development.log will give you a clue usually. If you are not using a
database for your application, you may want to remove the Database
configuration or comment it out, under the development section. Or if
you will be using one, set up an appropriate beginning database and
set the configurations in there correctly.

Hope that is of some help.

sean


#12

On Dec 31, 2005, at 8:46 AM, Barney T. wrote:

On 12/23/05, Barney T. removed_email_address@domain.invalid wrote:

  • Hide quoted text -
however, my program doesn't produce the expected output--it doesn't produce any output. After starting WEBrick, mozilla http://localhost:3000/ works fines (it produces a default greeting). But mozilla http://localhost:3000/say/hello/ doesn't (it produces a blank page). If you have any suggestions or tests that I can run-- let me know.

I’ve noticed that with Mozilla browsers, they will sometimes show a
blank page when Webrick serves up an error 500. I noticed this happen
usually when Rails is having difficulties connecting to a database,
or config/database.yaml is configured incorrectly. Looking at log/
development.log will give you a clue usually. If you are not using a
database for your application, you may want to remove the Database
configuration or comment it out, under the development section. Or if
you will be using one, set up an appropriate beginning database and
set the configurations in there correctly.

Also you can try starting up WEBRick in debug mode using the following
commnand
ruby -d script/server

After the debugger launches WEBRick, you can then request a page, and
see what is possibly causing the error. You’ll probably see a lot of
errors that are pretty normal, but scan through it and you might
recognize something that is yours.

Hope that is of some help.


Sean W.
master nerd of
i heart squares, Co.

3711 N. Ravenswood Ave. #147 Chicago, IL 60613
Ph. (773) 531-6301 Fx. (773) 529-7041
http://www.iheartsquares.com