annotate README.rdoc @ 13:33e8202c7e5d

Added example database.yml.
author Edho Arief <edho@myconan.net>
date Sun, 26 Aug 2012 12:06:48 -0700
parents 4aa8194a1733
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
1 == Welcome to Rails
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
2
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
3 Rails is a web-application framework that includes everything needed to create
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
4 database-backed web applications according to the Model-View-Control pattern.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
5
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
6 This pattern splits the view (also called the presentation) into "dumb"
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
7 templates that are primarily responsible for inserting pre-built data in between
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
8 HTML tags. The model contains the "smart" domain objects (such as Account,
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
9 Product, Person, Post) that holds all the business logic and knows how to
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
10 persist themselves to a database. The controller handles the incoming requests
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
11 (such as Save New Account, Update Product, Show Post) by manipulating the model
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
12 and directing data to the view.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
13
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
14 In Rails, the model is handled by what's called an object-relational mapping
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
15 layer entitled Active Record. This layer allows you to present the data from
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
16 database rows as objects and embellish these data objects with business logic
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
17 methods. You can read more about Active Record in
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
18 link:files/vendor/rails/activerecord/README.html.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
19
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
20 The controller and view are handled by the Action Pack, which handles both
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
21 layers by its two parts: Action View and Action Controller. These two layers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
22 are bundled in a single package due to their heavy interdependence. This is
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
23 unlike the relationship between the Active Record and Action Pack that is much
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
24 more separate. Each of these packages can be used independently outside of
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
25 Rails. You can read more about Action Pack in
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
26 link:files/vendor/rails/actionpack/README.html.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
27
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
28
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
29 == Getting Started
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
30
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
31 1. At the command prompt, create a new Rails application:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
32 <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
33
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
34 2. Change directory to <tt>myapp</tt> and start the web server:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
35 <tt>cd myapp; rails server</tt> (run with --help for options)
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
36
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
37 3. Go to http://localhost:3000/ and you'll see:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
38 "Welcome aboard: You're riding Ruby on Rails!"
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
39
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
40 4. Follow the guidelines to start developing your application. You can find
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
41 the following resources handy:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
42
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
43 * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
44 * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
45
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
46
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
47 == Debugging Rails
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
48
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
49 Sometimes your application goes wrong. Fortunately there are a lot of tools that
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
50 will help you debug it and get it back on the rails.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
51
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
52 First area to check is the application log files. Have "tail -f" commands
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
53 running on the server.log and development.log. Rails will automatically display
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
54 debugging and runtime information to these files. Debugging info will also be
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
55 shown in the browser on requests from 127.0.0.1.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
56
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
57 You can also log your own messages directly into the log file from your code
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
58 using the Ruby logger class from inside your controllers. Example:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
59
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
60 class WeblogController < ActionController::Base
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
61 def destroy
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
62 @weblog = Weblog.find(params[:id])
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
63 @weblog.destroy
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
64 logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
65 end
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
66 end
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
67
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
68 The result will be a message in your log file along the lines of:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
69
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
70 Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
71
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
72 More information on how to use the logger is at http://www.ruby-doc.org/core/
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
73
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
74 Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
75 several books available online as well:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
76
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
77 * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
78 * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
79
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
80 These two books will bring you up to speed on the Ruby language and also on
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
81 programming in general.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
82
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
83
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
84 == Debugger
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
85
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
86 Debugger support is available through the debugger command when you start your
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
87 Mongrel or WEBrick server with --debugger. This means that you can break out of
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
88 execution at any point in the code, investigate and change the model, and then,
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
89 resume execution! You need to install ruby-debug to run the server in debugging
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
90 mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
91
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
92 class WeblogController < ActionController::Base
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
93 def index
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
94 @posts = Post.all
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
95 debugger
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
96 end
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
97 end
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
98
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
99 So the controller will accept the action, run the first line, then present you
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
100 with a IRB prompt in the server window. Here you can do things like:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
101
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
102 >> @posts.inspect
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
103 => "[#<Post:0x14a6be8
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
104 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
105 #<Post:0x14a6620
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
106 @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
107 >> @posts.first.title = "hello from a debugger"
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
108 => "hello from a debugger"
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
109
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
110 ...and even better, you can examine how your runtime objects actually work:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
111
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
112 >> f = @posts.first
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
113 => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
114 >> f.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
115 Display all 152 possibilities? (y or n)
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
116
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
117 Finally, when you're ready to resume execution, you can enter "cont".
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
118
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
119
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
120 == Console
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
121
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
122 The console is a Ruby shell, which allows you to interact with your
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
123 application's domain model. Here you'll have all parts of the application
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
124 configured, just like it is when the application is running. You can inspect
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
125 domain models, change values, and save to the database. Starting the script
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
126 without arguments will launch it in the development environment.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
127
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
128 To start the console, run <tt>rails console</tt> from the application
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
129 directory.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
130
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
131 Options:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
132
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
133 * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
134 made to the database.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
135 * Passing an environment name as an argument will load the corresponding
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
136 environment. Example: <tt>rails console production</tt>.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
137
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
138 To reload your controllers and models after launching the console run
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
139 <tt>reload!</tt>
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
140
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
141 More information about irb can be found at:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
142 link:http://www.rubycentral.org/pickaxe/irb.html
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
143
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
144
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
145 == dbconsole
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
146
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
147 You can go to the command line of your database directly through <tt>rails
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
148 dbconsole</tt>. You would be connected to the database with the credentials
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
149 defined in database.yml. Starting the script without arguments will connect you
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
150 to the development database. Passing an argument will connect you to a different
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
151 database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
152 PostgreSQL and SQLite 3.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
153
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
154 == Description of Contents
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
155
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
156 The default directory structure of a generated Ruby on Rails application:
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
157
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
158 |-- app
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
159 | |-- assets
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
160 | |-- images
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
161 | |-- javascripts
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
162 | `-- stylesheets
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
163 | |-- controllers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
164 | |-- helpers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
165 | |-- mailers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
166 | |-- models
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
167 | `-- views
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
168 | `-- layouts
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
169 |-- config
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
170 | |-- environments
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
171 | |-- initializers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
172 | `-- locales
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
173 |-- db
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
174 |-- doc
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
175 |-- lib
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
176 | `-- tasks
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
177 |-- log
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
178 |-- public
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
179 |-- script
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
180 |-- test
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
181 | |-- fixtures
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
182 | |-- functional
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
183 | |-- integration
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
184 | |-- performance
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
185 | `-- unit
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
186 |-- tmp
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
187 | |-- cache
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
188 | |-- pids
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
189 | |-- sessions
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
190 | `-- sockets
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
191 `-- vendor
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
192 |-- assets
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
193 `-- stylesheets
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
194 `-- plugins
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
195
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
196 app
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
197 Holds all the code that's specific to this particular application.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
198
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
199 app/assets
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
200 Contains subdirectories for images, stylesheets, and JavaScript files.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
201
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
202 app/controllers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
203 Holds controllers that should be named like weblogs_controller.rb for
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
204 automated URL mapping. All controllers should descend from
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
205 ApplicationController which itself descends from ActionController::Base.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
206
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
207 app/models
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
208 Holds models that should be named like post.rb. Models descend from
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
209 ActiveRecord::Base by default.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
210
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
211 app/views
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
212 Holds the template files for the view that should be named like
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
213 weblogs/index.html.erb for the WeblogsController#index action. All views use
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
214 eRuby syntax by default.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
215
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
216 app/views/layouts
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
217 Holds the template files for layouts to be used with views. This models the
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
218 common header/footer method of wrapping views. In your views, define a layout
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
219 using the <tt>layout :default</tt> and create a file named default.html.erb.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
220 Inside default.html.erb, call <% yield %> to render the view using this
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
221 layout.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
222
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
223 app/helpers
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
224 Holds view helpers that should be named like weblogs_helper.rb. These are
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
225 generated for you automatically when using generators for controllers.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
226 Helpers can be used to wrap functionality for your views into methods.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
227
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
228 config
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
229 Configuration files for the Rails environment, the routing map, the database,
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
230 and other dependencies.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
231
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
232 db
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
233 Contains the database schema in schema.rb. db/migrate contains all the
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
234 sequence of Migrations for your schema.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
235
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
236 doc
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
237 This directory is where your application documentation will be stored when
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
238 generated using <tt>rake doc:app</tt>
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
239
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
240 lib
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
241 Application specific libraries. Basically, any kind of custom code that
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
242 doesn't belong under controllers, models, or helpers. This directory is in
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
243 the load path.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
244
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
245 public
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
246 The directory available for the web server. Also contains the dispatchers and the
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
247 default HTML files. This should be set as the DOCUMENT_ROOT of your web
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
248 server.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
249
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
250 script
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
251 Helper scripts for automation and generation.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
252
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
253 test
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
254 Unit and functional tests along with fixtures. When using the rails generate
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
255 command, template test files will be generated for you and placed in this
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
256 directory.
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
257
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
258 vendor
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
259 External libraries that the application depends on. Also includes the plugins
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
260 subdirectory. If the app has frozen rails, those gems also go here, under
4aa8194a1733 Initial.
Edho Arief <edho@myconan.net>
parents:
diff changeset
261 vendor/rails/. This directory is in the load path.