Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Last active July 10, 2019 06:06
Show Gist options
  • Select an option

  • Save harrisonmalone/a53bbb2fcce5acba0da95113e1d9609c to your computer and use it in GitHub Desktop.

Select an option

Save harrisonmalone/a53bbb2fcce5acba0da95113e1d9609c to your computer and use it in GitHub Desktop.

challenges this week

Artists, albums, tracks

  • CRUD operations for artists, albums, and tracks, with the following stipulations:
  • The root route will be the same as the artists index page.
  • Artists must have at least name, year of birth, and whether they are currently active (and as many others as you would like - this applies to all resources).
  • Albums must have attributes of (at least) title, year, and length.
  • Tracks must have title and length.
  • Artists will have many albums, but albums have one and only one artist.
  • Albums can have many tracks (or none), and tracks can have many albums (but at least one)
  • Seed your database with a few of each resource using the seed file or console (I can help by adding to the seed file if required, although you may need to modify the file based your your resource configurations).
  • Provide index pages for each of artists, albums and tracks
  • Provide a link to add a new artist on the artist index page (and a new artist page to add an artist).
  • Provide navigation links up the top of the page (that remain on every page) that link to the artists, albums, and tracks index pages.
  • Show, edit, and delete options also available on the index page of every resource (artists, albums, and tracks), including show pages available through a link via the listed entity (that is, if on the index page you see “Beyonce”, you can click the string “Beyonce” to get to the show page for the artist).
  • New albums are only to be added on the artists show page (so the album would be added to that specific artist, and albums must be tied to an artist).
  • The album index page must not have any way to add a new album.
  • The album show page lists all the tracks added to this album, or informs the user that there are no tracks added to this album as yet.
  • The album show page also has two ways to add a track to the album. The track can be added by choosing from a list of tracks already on the database (where the track is assumed to be added to the album featured on the show page). Or you can add a totally new track (again, that will be added to the current album).
  • A link to create a new track is on the tracks index page. Following that link presents a form. The form will provide field for all the elements of the track, and a drop down list of albums to choose from to add the track to.
  • The track show page will also list the albums that the track appears on.
  • Every page should have appropriate links to move comfortably through the site. Install the Devise gem. Follow the steps carefully.
  • Make sure you also have all the Devise views.
  • Put the sign-in and logout options into the navbar.
  • Add a comments section for the artists page.
  • Add a form to accept a new comment below the form to add an album (with an appropriate heading above it).
  • If there are any comments for this artist, they should appear in a list below the form (or the form can come after if you like).
  • Each comment should have some information about the user who made the comment, and the content.
  • If there are no comments then the user should be informed about this.
  • Now have a user be able to edit or delete a comment.
  • Make sure that the user can only edit/delete their own comment.

Extension

  1. Think through the tables and relationships for an implementation of ‘likes’ on albums.
  2. Each user is going to have many likes (of albums), but can only like each album once.
  3. Each album can have many likes (from different users).
  4. Use a helper method to show the number of likes for each album.
  5. Use a helper method to show whether the album has been liked by the current user.

Dogs and parks

  1. Add to parks dogs app, as a user I should be able to upload an image of a park to my parks form
  2. As a user I should be able to go to a form and select a favourite park, they should then see these parks on their dog page

Dogs and parks extension

  1. Add users to the app.
  2. Only users signed in can add dogs.
  3. Users must have a profile.
  4. The profile will be a has_one and belongs_to relationship. Have a go at this, and we can run through it later.
  5. Have your user be able to add dogs, and display those dogs on their profile.
  6. Have it so that anyone can add a park, but it must have an image (and each park can have several images.
  7. Let users add parks to their favourite parks.
  8. Display the favourite parks on the user’s profile page.
  9. Be able to link a particular dog and a park, and have that be that dog’s favourite park (which is only allowed by the dog’s owner (user) (you might need a button to ‘set park as a dog’s favourite), and on the new page you list the dog’s that the current user has who do not have a favourite.
  10. Show the dog’s favourite park on the dog’s show page.
  11. Now give the user a button to be able to unfavourite the favourited park.

Zoos and animals

bit.ly clone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment