ngpestelos (owner)

Revisions

gist: 184224 Download_button fork
public
Public Clone URL: git://gist.github.com/184224.git
Embed All Files: show embed
Creating a Rails Application #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)