https://www.youtube.com/watch?v=cFsWchQ7lDs&list=PLjbL0BCR04Q13ph3TLp3dPsYQi7ujH6R4 PAIR PROGRAMMING ON HW2Please do see if you can join a pair programming session when attempting this homework. Follow the instructions in the pair programming tab, and please do create your own G+ pair programming event (ensuring it is set to "hangout" in the advanced options) if you can't find one at a time that suits you. Remember that showing complete solutions to others who are just starting the homework prevents learning and is against the edX honor code. HW2: Rails INtro - Add Features to RottenPotatoesSkeleton: Click here In this homework you will add a feature to an existing simple Rails app and deploy the result publicly on the Heroku cloud hosting service. We will run live integration tests against your deployed version. General advice: This homework involves modifying RottenPotatoes in various ways. Git is your friend: commit frequently in case you inadvertently break something that was working before! That way you can always back up to an earlier revision, or just visually compare what changed in each file since your last “good” commit. Remember, commit early and often! Preparation: If you've never used Rails before please follow these screencasts to work through chapter 4 of the ESaaS textbook to create a rottenpotatoes rails app from scratch. This assignment assumes that you have a working version of RottenPotatoes running locally and deployed on Heroku. Please follow these steps to make an initial deployment to Heroku: Switch to the rottenpotatoes directory that you've unzipped from the skeleton (see link above)
Now you need to install various libraries with the bundle command
Now you can test the app locally by running the following and navigating to http://localhost:3000 in your browser
Now you need to initialize a git repository to put the code in
Then add all the files in the rottenpotatoes directory
Commit those changes to the local repository
In order to deploy to Heroku you will need to install Heroku Toolbelt on your VM. First, sign up for a free Heroku account at https://id.heroku.com/signup and follow the instructions to create your account. Unfortunately there is currently a bug with the Heroku Toolbelt install script on Linux, but you can work around it as follows:
The above downloads an installation script, that is made executable with the following command
and then can be run with this next command
Now you will likely get the following error: 'E: There are problems
and -y was used without --force-yes ' which you can fix with the
following: Assuming you have heroku toolbelt installed you now need to set up ssh keys to securely talk to Heroku. The three basic commands you need are the following, but see the Heroku page for more details.
Once you have your heroku keys set up correctly you can create a heroku instance from the rottenpotatoes directory
Now we can use git to deploy our code to the Heroku server in the cloud
Note, if you see a warning such as: The authenticity of host 'heroku.com (50.19.85.132)' can't be established. This is normal - go ahead and type yes then <ENTER> to add heroku to the list of known hosts. Next we need to tell the cloud instance to prepare the database:
We need to tell the cloud instance to add some data to the database:
Now you can navigate to the heroku url that heroku create printed to the console and see your app running in the cloud. You can find more details on git and Heroku in the appendices of the ESaaS textbook. Note on submissionIf you are pair programming each student must deploy the result separately on his or her own Heroku account. The changes you must make in parts 1-3 are cumulative, so when all done, you should deploy your working version to Heroku. We will test the features in each part separately, so you WILL get partial credit if you have a subset of the features working. PART 1: SORTING THE LIST OF ALL MOVIES (15 points)Enhance RP in the following way: On the list of all movies page, the column headings for ‘Movie Title’ and ‘Release Date’ for a movie should be clickable links. Clicking one of them should cause the list to be reloaded but sorted in ascending order on that column. For example, clicking the ‘release date’ column heading should redisplay the list of movies with the earliest-released movies first; clicking the ‘title’ field should list the movies alphabetically by title. (For movies whose names begin with non-letters, the sort order should match the behavior of String#<=>.) IMPORTANT for grading purposes:
When the listing page is redisplayed with sorting-on-a-column
enabled, the column header that was selected for sorting should appear
with a yellow background, as shown below. You should do this by setting
controller variables that are used to conditionally set the CSS class of
the appropriate table heading to
The result should look something like this: Hints and caveats:
You'll submit this part after you deploy on Heroku and when you supply your Heroku deployment URL in part 3. PART 2: FILTER THE LIST OF MOVIES (15 points)Enhance RottenPotatoes as follows. At the top of the All Movies listing, add some checkboxes that allow the user to filter the list to show only movies with certain MPAA ratings: When the Refresh button is pressed, the list of movies is redisplayed showing only those movies whose ratings were checked. This will require a couple of pieces of code. We have provided the
code that generates the checkboxes form, which you can include in the
BUT, you have to do a bit of work to use the above code: as you can
see, it expects the variable @all_ratings to be an enumerable collection
of all possible values of a movie rating, such as You will also need code that figures out (i) how to figure out which boxes the user checked and (ii) how to restrict the database query based on that result. Regarding (i), try viewing the source of the movie listings with the
checkbox form, and you’ll see that the checkboxes have field names like Regarding (ii), you’ll probably end up replacing IMPORTANT for grading purposes:
Hints and caveats:
You'll submit this part after you deploy on Heroku and when you supply your Heroku deployment URL in part 3. PART 3: REMEMBER THE SORTING AND FILTERING SETTINGS (70 points)OK, so the user can now click on the “Movie Title” or “Release Date” headings and see movies sorted by those columns, and can additionally use the checkboxes to restrict the listing to movies with certain ratings only. And we have preserved RESTfulness, because the URI itself always contains the parameters that will control sorting and filtering. The last step is to remember these settings. That is, if the user has selected any combination of column sorting and restrict-by-rating constraints, and then the user clicks to see the details of one of the movies (for example), when she clicks the Back to Movie List on the detail page, the movie listing should “remember” the user’s sorting and filtering settings from before. (Clicking away from the list to see the details of a movie is only one example; the settings should be remembered regardless what actions the user takes, so that any time she visits the index page, the settings are correctly reinstated.) The best way to do the “remembering” will be to use the Hints and caveats
HOW TO SUBMIT:Deploying your finished app to Heroku by the homework deadline is part of the grading process. Even if you have code checked in that works properly, you still need to also deploy it to Heroku to get full credit. Deploy to Heroku by following the same process as in the Section 1 worksheet, Developer Workflow. You may also need to install Heroku toolbelt. The commands You will submit the URI of your deployed Heroku app in a text file with no other contents. |