Created
January 20, 2012 22:48
-
-
Save mikeymicrophone/1650054 to your computer and use it in GitHub Desktop.
This file contains 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
A Rails app has a few top-level folders that serve different purposes. This might vary from app to app, but most apps use this basic structure pretty faithfully. | |
app | |
This folder is where most of your code goes. It has folders for your controllers (navigation logic), models (business logic), and views (display templates). Sometimes developers create extra folders in here for objects like mailers and observers. In Rails 3.1, an assets folder joined this group. The assets folder contains files that get compiled into javascript code, stylesheets, and images. These asset files are written in Ruby-like languages, but the rest of the code in the app folder is Ruby. | |
config | |
This folder has files that run when your app starts, including environment.rb and database.yml. They control decisions about how the app works in different scenarios (examples: which email account should be used for outgoing messages? which database should be used for data stored by this server?). The config folder also contains credentials that allow your code to connect to services (such as an Amazon account for storing images, or a Facebook app for querying the 'book). Account details like that should be secret, and are usually left out of the repository so they don't get accidentally shared. There is also an initializers folder that contains any code that you need to be run right after the app starts. | |
db | |
This folder contains 3 things - a set of migrations that collectively define the structure of your database, a schema.rb file that shows you the ultimate result of the migrations, and a seeds.rb file that you can use to put starter data into a new database. | |
doc | |
This is just a storage area for you to create any documentation that you see fit. | |
lib | |
This is a folder for code that's not really part of your app, for some reason. If you have small files that change the way some other tool works, you can put them here. There is also a folder here called tasks that stores your Rake tasks (actions that you control without coming in via the web server). | |
log | |
Rails creates logs while it runs - they are files that give you certain details about what happened. They are placed in this folder. | |
public | |
This is a folder for files that work without Rails taking part at all. Images are an example (although in Rails 3.1 those are moved to the app/assets folder). Another example might be a static (unchanging) page that can be displayed without running any code. | |
script | |
This folder contains programs that you can run while you're working on the app. In the past there were a handful, but they've all been combined into the rails command itself. | |
spec/test | |
These folders contain code that tests your code. | |
tmp | |
Your app can use this folder to create files that don't need to be saved for very long. | |
vendor | |
This folder can be used to store plugins and gems that your app uses. Typically you don't need to put them here though - that's kind of the old way of doing it. Sometimes you run into a situation where it's easier to put a gem in here than to just rely on your server's environment though. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment