On Nov 24, 9:41Ā pm, "Mr. Watson" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I created a controller named animals and a .rhtml file called hello.
>
> There is nothing in the controller, but there is "hello, world!" in
> the .rhtml.
>
> I booted up webbrick and typed "http://localhost:3000/animals/hello"
> and it should have displayed "hello, world!" instead it gave me this
> error.
>
> Ā MissingSourceFile in AnimalsController#hello
Hey there. To create a basic, custom controller action, you need to do
three things:
1) Create a method in the controller. In your case you'd need:
class AnimalsController < ApplicationController
def hello
end
end
2) Create a view template for the action to render. In your case,
you'd need app/views/animals/hello.html.erb .
3) Create a route to the custom controller action. In your case, you'd
need this in config/routes.rb :
map.resources :animals, :collection => :hello
Since you're getting started with Rails, I highly recommend reading
through Agile Web Development With Rails:
http://www.pragprog.com/titles/rails3/
Cheers,
Nick
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---