Skip to content

Instantly share code, notes, and snippets.

@ngpestelos
Created September 10, 2009 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngpestelos/184224 to your computer and use it in GitHub Desktop.
Save ngpestelos/184224 to your computer and use it in GitHub Desktop.
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