In this exercise you will create an application that will give your user a single well formatted compliment every time they refresh the page.
Examples:
-
Create a Sinatra application that has a single route
/compliments
. -
Create a model,
compliment.rb
and put it in yourlib
folder. Every new object should have an instance variable,message
, that contains a random compliment and an instance variable,image
, that has a random cute or funny image. Feel free to make your emergency compliment page themed. -
Create a single view,
compliment.erb
, and put it in your views folder. This view should be rendered when the user hits the/compliments
route and should show the message and image of a Compliment object. -
Create a
layout.erb
file and put it in your views folder. In this file you should scaffold a basic HTML5 page. Place<%= yield %>
inside the<body>
tag. -
Create a
styles.css
file and put it in your public folder. Make sure this file is linked in your layout. Use this to apply some styles to your view.
** NOTE ** Try your best to keep all of your logic out of your views and inside your route in app.rb
or your model.
- include twitter bootstrap and make your site responsive
- use a google font! or three.
- write logic that picks a random style (i.e. background color, text color, etc)
- write logic that prevents the same image or message from appearing twice in a row
- create a unique route for every compliment so that it can be linked back to individually later (we'll be going over this tomorrow, but if you have the time, try it out!)