mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use the controller name 'Greetings' consistently.
Moreover, there seems to be a bug in Rails 2.3.0: After editing the view file apps/views/greetings/hello.html.erb in Vim, WEBrick ships the outdated content from the backup file apps/views/greetings/hello.html.erb~ instead of the intended content. Only when the 'tilde backup' file is not present, the browser shows the correct contents (both Konqueror and Firefox; you can even add a _different_ hello.html.erb~ to show completely different stuff). This bug does not occur in Rails 2.2.2.
This commit is contained in:
parent
11b15d2de2
commit
8eb7ad21cc
1 changed files with 7 additions and 5 deletions
|
@ -126,10 +126,10 @@ Modules Example:
|
|||
Ah, the controller generator is expecting parameters in the form of +generate controller ControllerName action1 action2+. Let's make a +Greetings+ controller with an action of *hello*, which will say something nice to us.
|
||||
|
||||
<shell>
|
||||
$ ./script/generate controller Greeting hello
|
||||
$ ./script/generate controller Greetings hello
|
||||
exists app/controllers/
|
||||
exists app/helpers/
|
||||
create app/views/greeting
|
||||
create app/views/greetings
|
||||
exists test/functional/
|
||||
create app/controllers/greetings_controller.rb
|
||||
create test/functional/greetings_controller_test.rb
|
||||
|
@ -139,10 +139,10 @@ $ ./script/generate controller Greeting hello
|
|||
|
||||
Look there! Now what all did this generate? It looks like it made sure a bunch of directories were in our application, and created a controller file, a functional test file, a helper for the view, and a view file.
|
||||
|
||||
Let's check out the controller and modify it a little (in +app/controllers/greeting_controller.rb+):
|
||||
Let's check out the controller and modify it a little (in +app/controllers/greetings_controller.rb+):
|
||||
|
||||
<ruby>
|
||||
class GreetingController < ApplicationController
|
||||
class GreetingsController < ApplicationController
|
||||
def hello
|
||||
@message = "Hello, how are you today? I am exuberant!"
|
||||
end
|
||||
|
@ -150,7 +150,7 @@ class GreetingController < ApplicationController
|
|||
end
|
||||
</ruby>
|
||||
|
||||
Then the view, to display our nice message (in +app/views/greeting/hello.html.erb+):
|
||||
Then the view, to display our nice message (in +app/views/greetings/hello.html.erb+):
|
||||
|
||||
<html>
|
||||
<h1>A Greeting for You!</h1>
|
||||
|
@ -164,6 +164,8 @@ $ ./script/server
|
|||
=> Booting WEBrick...
|
||||
</shell>
|
||||
|
||||
WARNING: Make sure that you do not have any "tilde backup" files in +app/views/(controller)+, or else WEBrick will _not_ show the expected output. This seems to be a *bug* in Rails 2.3.0.
|
||||
|
||||
The URL will be +http://localhost:3000/greetings/hello+. I'll wait for you to be suitably impressed.
|
||||
|
||||
INFO: With a normal, plain-old Rails application, your URLs will generally follow the pattern of http://(host)/(controller)/(action), and a URL like http://(host)/(controller) will hit the *index* action of that controller.
|
||||
|
|
Loading…
Reference in a new issue