CSC/ECE 517 Fall 2013/ch1 1w27 ma: Difference between revisions
Jump to navigation
Jump to search
Line 21: | Line 21: | ||
<tr> | <tr> | ||
<th><span style=" | <th><span style=""><strong>File/Directory</strong></span></th> | ||
<th><span style=" | <th><span style=""><strong>Purpose</strong></span></th> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>app/</code></span></td> | ||
<td><span style=" | <td><span style="">Core application (app) code, including models, views, controllers, and helpers</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>app/assets</code></span></td> | ||
<td><span style=" | <td><span style="">Applications assets such as cascading style sheets (CSS), JavaScript files, and images</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>config/</code></span></td> | ||
<td><span style=" | <td><span style="">Application configuration</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>db/</code></span></td> | ||
<td><span style=" | <td><span style="">Database files</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>doc/</code></span></td> | ||
<td><span style=" | <td><span style="">Documentation for the application</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>lib/</code></span></td> | ||
<td><span style=" | <td><span style="">Library modules</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>lib/assets</code></span></td> | ||
<td><span style=" | <td><span style="">Library assets such as cascading style sheets (CSS), JavaScript files, and images</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>log/</code></span></td> | ||
<td><span style=" | <td><span style="">Application log files</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>public/</code></span></td> | ||
<td><span style=" | <td><span style="">Data accessible to the public (e.g., web browsers), such as error pages</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>script/rails</code></span></td> | ||
<td><span style=" | <td><span style="">A script for generating code, opening console sessions, or starting a local server</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>test/</code></span></td> | ||
<td><span style=" | <td><span style="">Application tests</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>tmp/</code></span></td> | ||
<td><span style=" | <td><span style="">Temporary files</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>vendor/</code></span></td> | ||
<td><span style=" | <td><span style="">Third-party code such as plugins and gems</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>vendor/assets</code></span></td> | ||
<td><span style=" | <td><span style="">Third-party assets such as cascading style sheets (CSS), JavaScript files, and images</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>README.rdoc</code></span></td> | ||
<td><span style=" | <td><span style="">A brief description of the application</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>Rakefile</code></span></td> | ||
<td><span style=" | <td><span style="">Utility tasks available via the <code>rake</code> command</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>Gemfile</code></span></td> | ||
<td><span style=" | <td><span style="">Gem requirements for this app</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>Gemfile.lock</code></span></td> | ||
<td><span style=" | <td><span style="">A list of gems used to ensure that all copies of the app use the same gem versions</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>config.ru</code></span></td> | ||
<td><span style=" | <td><span style="">A configuration file for Rack middleware</span></td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style=" | <td><span style=""><code>.gitignore</code></span></td> | ||
<td><span style=" | <td><span style="">Patterns for files that should be ignored by Git</span></td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
=== Naming conventions === | === Naming conventions === |
Revision as of 02:22, 16 September 2013
MVC architecture structure in Ruby on Rails
What is MVC
MVC is a design pattern and was developed in 1979 by Trygve Reenskaug. MVC dictates that the system be split into three distinct parts, a Model, View and Controller. This approach organizes the code into separate components, thereby facilitating maintainability.
Model
- The Model generally contains the data for the application and is usually linked to a database back-end. This is the data structure that the application uses.
- It contains the application state and also most of the business logic. The model has no knowledge of the user interfaces.
View
- The view refers to the interface that is presented to the end-user. The view does not do any processing, but simply acts as the presentation layer, displaying the application data.
Controller
- The controller receives events from the outside world [ or through some view] and performs some processing
It interacts with the model and redirects to the appropriate view.
MVC Rails
Directory Structure
File/Directory | Purpose |
---|---|
app/ |
Core application (app) code, including models, views, controllers, and helpers |
app/assets |
Applications assets such as cascading style sheets (CSS), JavaScript files, and images |
config/ |
Application configuration |
db/ |
Database files |
doc/ |
Documentation for the application |
lib/ |
Library modules |
lib/assets |
Library assets such as cascading style sheets (CSS), JavaScript files, and images |
log/ |
Application log files |
public/ |
Data accessible to the public (e.g., web browsers), such as error pages |
script/rails |
A script for generating code, opening console sessions, or starting a local server |
test/ |
Application tests |
tmp/ |
Temporary files |
vendor/ |
Third-party code such as plugins and gems |
vendor/assets |
Third-party assets such as cascading style sheets (CSS), JavaScript files, and images |
README.rdoc |
A brief description of the application |
Rakefile |
Utility tasks available via the rake command |
Gemfile |
Gem requirements for this app |
Gemfile.lock |
A list of gems used to ensure that all copies of the app use the same gem versions |
config.ru |
A configuration file for Rack middleware |
.gitignore |
Patterns for files that should be ignored by Git |