Joe 3000 wrote:> I have just started looking at Ruby on Rails and am following a book
> ''Beginning Ruby on Rails''.
>
> The first exercise is to display a webpage but when entering the url in
> Firefox it doesnt display.
>
> I get this error message:
>
> Page title:
>
> Action Controller: Exception caught
>
> Page body:
>
> Routing Error
>
> no route found to match "/app/greeting" with {:method=>:get}
>
> -
>
> All I did was add these lines:
> def greeting
> end
>
> to application.rb so it now looks like:
> # Filters added to this controller apply to all controllers in the
> application.
> # Likewise, all the methods added will be available for all controllers.
>
> class ApplicationController < ActionController::Base
> # Pick a unique cookie name to distinguish our session data from
> others''
> session :session_key => ''_hello_session_id''
> def greeting
> end
> end
>
> Any ideas?
>
> Thanks.
I''ve never seen that book, but as far as I know the
"application.rb"
file is not meant to be used that way. What you need to do is generate a
new controller and put "def greeting" in there. For example in the
console/command line type:
/script/generate controller test
That should create a file called "test_controller.rb". Open that file
and put "def greeting" in there. The URL will then be
"/test/greeting".
Of course, you also need to create a view for greeting called
"greeting.rhtml" that conatins some HTML, or you need to render text
directly in the controller.
Anyway, I don''t want to get into a major rails tutorial. I mainly
wanted
to point out the usual way to start up a rails application. Sounds like
that book may be a bit too complicated for the basics or you''re not
following it correctly. I recommend you look at the following very, very
simple and well written A-Z tutorial:
http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---