Ruby on Rails
UnderstandingWhatFilesGoesWhere

app
    apis
    controllers
    helpers
    models
    views
        layouts
config
    environments
components
db
doc
    app
lib
    tasks
log
public
    images
    javascript
    stylesheets
script
test
    fixtures
    functional
    mocks
        development
        test
    unit
vendor

app/

The app directory is meant for all the Rails code that’s specific to the particular application.

app/controllers/

Holds controllers that should be named like weblog_controller.rb for automated URL mapping. All controllers should have ActionController::Base somewhere in their ancestor tree. Most controllers descend directly from ApplicationController as this is the convenient default of the controller generator.

app/controllers/application.rb

There’s one special controller called ApplicationController, which is defined in the file application.rb. All filters added to this controller will be run for all controllers in the application. Likewise, all the methods of this controller will be available for all controllers.

This is a particularly good place to set a standard layout for your application.

app/models/

Holds models that should be named like post.rb. Most models will descend from ActiveRecord::Base.

Observers can also be found here.

app/views/

Holds the template files for the view that should be named like weblog/index.rhtml for the WeblogController#index action. All views uses eRuby syntax. This directory can also be used to keep stylesheets, images, and so on that can be symlinked to public.

app/views/layouts/

Layouts for your views. These can be selected using the “layout” method in your controllers. A good example:
<pre> class ApplicationController < ActionController::Base layout "standard-layout" end </pre>

app/helpers/

Holds view helpers that should be named like weblog_helper.rb. These are intended to
simplify views logic.

app/apis

Used in the creation of ActionWebService services.

config/

Configuration files for the Rails environment, the routing map, the database, and other dependencies.

components/

Self-contained mini-applications that can bundle controllers, models, and views together.

doc/

Documentation for Rails and/or your Rails based application.

doc/api/

Rails API documentation and reference. Run “rake apidoc” in the top-level directory to build this documentation set.

doc/app/

All documentation pertaining to this application.
Run “rake appdoc” in the top-level directory to build this documentation.

doc/README_FOR_APP

Whatever is written in this file will form the introduction in your application docs.

lib/

Application specific libraries. Basically, any kind of custom code that doesn’t belong in controllers, models, or helpers. This directory is in the load path.

lib/tasks/

Custom Rake tasks. Files with a .rake extension will be loaded by and available to Rake.

public/

The directory available for the web server. Contains sub-directories for images, stylesheets, and javascripts. Also contains the dispatchers and the default HTML files.

script/

Helper scripts for automation and generation. See UnderstandingTheScriptFiles.

test/

Unit and functional tests along with fixtures.

A Guide to Testing the Rails is a very good introduction into how and why to use tests and fixtures.

test/fixtures/

test/fixtures holds sample data in CSV or YAML format.
See http://manuals.rubyonrails.com/read/chapter/26 from A Guide to Testing the Rails for more information on fixtures.

test/functional/

In the test/functional directory, stubs for functional tests are created for each controller you create using “ruby scripts/generate controller”.

test/mocks/

The test/mocks directory is meant for mock objects that you use for testing.

test/mocks/development

test/mocks/development contains mock objects that are used with your development database.

test/mocks/test

test/mocks/test can contain mock object to be used with your test database.

test/unit

The test/unit directory gets the stub of a new unit test when you create a new model using “ruby scripts/generate model”.

vendor/

External libraries that the application depend on. This directory is in the load path.

Discussion

Most of this has simply been copied from the README file as generated by “rails myapp”. Perhaps a reference to this wiki page from the README could be useful?