Created
September 10, 2009 01:15
-
-
Save ngpestelos/184224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You're new to Rails and would like to create an application. | |
1. Generating the starting app | |
$ rails demo | |
$ cd demo | |
$ ls -p | |
README config/ lib/ script/ vendor/ Rakefile db/ log/ test/ app/ doc/ public/ tmp/ | |
2. Creating a controller | |
$ script/generate controller Say | |
This will generate several files. The file app/controllers/say_controller.rb is what we want at this point. | |
3. Creating an action | |
In app/controllers/say_controller.rb: | |
class SayController < ApplicationController | |
def hello | |
end | |
end | |
4. Starting the server | |
$ script/server | |
5. URL | |
http://localhost:3000/demo/say/hello | |
where | |
http:// is the protocol | |
localhost:3000 is the server and the port | |
demo is the app | |
say is the controller | |
hello is the action | |
6. HTML template | |
In app/views/say/hello.html.erb | |
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
<h1>Hello</h1> | |
</body> | |
</html> | |
See Also: | |
1. Agile Web Development with Rails, 3rd ed. (Chapter 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment