Alamo Records is a online store that sells vintage vinyl records. It is built on the Ruby on Rails web framework and consists of the following models:
- Publisher - a publisher sells albums.
- Album - albums are sold by publishers and include many songs.
- Song - a song is recorded onto one album. It is written by one artist.
- Artist - an artist writes songs.
The relationships between models are represented in the following diagram:
Fork the repository, prepare the application and complete each of the tasks listed below. Tasks include styling changes, adding functionality, fixing bugs and writing tests. Each task should be committed separately into Git with a commit message that includes the task number and a short summary of the task.
Do not add any additional gems to the application.
Complete as many tasks as you can in four hours and then submit a pull request through Github.
- On the publishers index page, change the
H1
element to the color#054491
. - On the navigation bar, add a link to the latest song.
- Some pages are executing too many queries. Fix them.
- In the song model, create a scope called
recent
that takes an argumentn
(the number of songs) and returns only the lastn
songs released during the past 6 months. - On the new/edit album pages, replace the publisher text field with a dropdown that displays each publisher's name.
- Add code to ensure that when an album is saved, a publisher is required.
- On the album index page, add a delete button for each album that, when pressed, deletes the album via ajax and removes the row from the page.
- In the footer, under the LATEST section, display the 5 most recent songs released.
- Use a caching technique to prevent this query from executing every request.
- On the artist show page, duplicate albums are being displayed in some cases. Fix this.
- Run the tests and fix all that fail.
- Write tests for the delete button you added in task 7.
- Some users have requested an API so they can access Alamo Record data in JSON format. In as little code as possible, enable this functionality.
- This is your final task. Alamo Records would like to change the artist index page from a table to a grid of artist profile image links. There are no artist profile images available, however, we can use the https://randomuser.me/ service to request fake user data including profile images. Your solution should meet the following requirements:
- The artist index page should display a responsive grid of artist profile images. Use the bootstrap grid columns classes
.col-lg-x
,.col-md-x
,.col-sm-x
, and.col-xs-x
to accomplish this. - The profile images should link to the artist show page.
- Initially, the profile images will not exist and a placeholder image should be shown on the artist index page.
- Once a user navigates to the artist show page, and if there is no profile image, an api request should be made to https://randomuser.me to request data for a user. Using the data returned, save the image url to a field on the artist model. Subsequent requests to the same artist should not generate an api call. Write tests for this requirement.