Open Source Starter Guide for IBM i Developers by Pete Helgren

Open Source Starter Guide for IBM i Developers by Pete Helgren

Author:Pete Helgren
Language: eng
Format: epub
Publisher: MC Press
Published: 2017-04-04T04:00:00+00:00


Structure of a Rails Project

Figure 7.1 shows the beast you create with rails new:

Figure 7.1: Sample Rails project components

The app folder is where most of the code for your app lives. We’ll circle back to it in a second. The bin folder is where the gem wrappers (binstubs) live. These were introduced in Rails version 4 and provide a way for multiple Rails and Ruby environments to coexist. The config folder is where the configuration scripts and properties live, so that you can configure database connections, routes for your application, and a bunch of other options. The db folder is where your database schemas will live along with migrations, a cool feature of Rails that we’ll explore momentarily. The lib folder will contain extended modules for your application. The log folder will contain (right you are!) logs generated by your application. The public folder will contain static content that your base app will serve. The test folder will contain your unit tests if you decide to create them. The tmp folder will contain temporary files that your application might generate, such as cache files and PID references.

We already covered the Gemfile, but the Rakefile is something worth noting here. Rake is a task-oriented script file that will execute a series of rake commands. Rake is similar to the makefile in C in that you can set configuration options and run steps in sequence to build or modify your application. It is basically a task-automation tool.

So, back to the app folder. This folder contains subfolders for the application structure. You should immediately see the model, view, and controller folders and get a sense of what they do. model will be empty for now because we really don’t have an app designed, so no logic for it has been written. view has a layout folder in it, and that is where your .erb templates will live that apply to the entire app. This structure can get quite complex over time as partials are added for other controllers that might be created. But, generally, your templates live here. The controller folder will house the classes that control input from your users and access to your Web pages.

There are a couple of other folders in the app folder that fall outside the MVC convention. The assets folder has images, JavaScript, and CSS content that is served by your app. The helpers folder contains small sections of code that usually render a component of a page (view) so you aren’t cluttering up your controller folder. The mailers folder will contain code for your email functions should your application need them. Rails’ Action Mailer is your friend here.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.