For this starter project, you will install Rails, create a scaffolded application and experiment with its various components. While no submission is required, completing this assignment will give you a good start on the first submitted project.
For this project, you will need to think of a simple application for development. Its data model should consist of entries, each with a list of properties (e.g. name, comment, price, rating, date). Your web application will then provide the means for creating, viewing and editing entries. Here are some possibilities:
The "Shovell" application in the text is another example. However, if you choose an article-sharing application, your application should have some significant differences from the application in the text.
With the idea for your application, specify the data model. This includes working out the needed attributes and their types.
Before you begin development, you will need to install Ruby and Rails for your computer. The text provides detailed instructions for installing on Windows, Mac OS X and Linux (see chapter 2). For Windows computers, InstantRails is highly recommended. Get the most recent version to install and then update to the latest version as presented in the book.
Using a simple name for your application, (e.g. "journal"), create
an application directory structure as explained in the book
(pp. 40-43) using the rails command (e.g. rails
journal).
You can work with whatever text editor you feel comfortable. I will probably use jEdit for class examples and it is available on all platforms.
To generate the scaffolded application, you may take an incremental approach as presented in chapter 5. Here the model is first created (bottom p. 121) followed by the rake command (p. 131). Then, the controller is created (p. 140). However, you can skip to the last step, which generates the scaffold (p. 146). If the data model and the controller are not created yet, this last step will automatically create these components. However, you will still need to issue the rake command (p. 131) before you run the server.
We will go through this process with a similar example in class.
At this point, you should be able to run the server to see your application working.
Perform at least one customization to each of the three components (Model, Controller, View).
One possible customization involves requiring a value for an attribute in the data model. That is, an error is produced if the user leaves a data field empty when creating a new entry. Specifying a required value can be done by editing the data model file found in the app/models folder. An example can be found on p. 175.
The controller allows you to perform calculations and set them to instance variables that can then be displayed in a view (see pp. 150 - 151). Here are some possibilities:
@time = Time.nowThe @time variable can then be referenced in a view with the following:
<%= @time %>
Here's another example
@average = (@entry.rating1 + @entry.rating2 + @entry.rating3) / 3
You could then reference the average in view:
<%= @average %>These customizations would require making changes to a controller (found in the app/controllers folder) and to a view template (found in the app/views folder).
View customizations should include changes to template files (found in app/views) and to the style file (found in the public/stylesheets folder). In addition to showing additional information calculated in the controller, you can re-organize the content in the view by modifying the HTML code. Editing the CSS code in the stylesheet allows you to modify visual properties such as fonts and color. You may want to consult these references for HTML and CSS.