Code Monkey home page Code Monkey logo

sinatra-jams-ii's Introduction

๐ŸŽง Jams ๐ŸŽง

Welcome to your second day of work at Jams Incorporated! Your manager is very impressed with the work that you did yesterday in setting up the website for Jams Incorporated's Artists, so they have tasked you with a couple of more tasks to make the website bigger and better.

Your manager says that in addition to logging an Artist with their name, bio and age, the website should be able to log the Instruments that each artist plays. And because Jams Incorporated works with only the best of the best, an artist can play multiple instruments. But keep in mind that with popular instruments like the piano and the keytar, there can be multiple artists playing them. ๐ŸŽน

At this point, you should be considering the relationship between an Artist instance and an Instrument instance. How would an artist keep track of all the instruments that they play and how would you know about all the artists playing a specific instruments?

Setting the Stage

In recording the instruments in the database, Jams Inc. would like to see the following deliverables implemented:

  • A database of Instruments that will allow for a name string and a brand string. If you create your database properly, you should be able to seed your database with the given seeds.rb file.

  • A feature to keep track of which artists play which instruments. This feature should be designed with the intention to keep the Single Source of Truth in regards to their relationship intact, which means you may need to alter your database somehow. Where should this relationship live?

    • After you figure out a way to keep track of which artists play which instruments, alter the seeds.rb file so that some artists and instruments are related. Implement this however way it makes sense to you, but make sure that you checkout your relationships in rake console.
  • In a specific artist's show page, the names of the instruments that the artist plays should be dynamically listed. When you're building out this feature, make sure that you're being cognizant of the MVC framework.

    • A nice to have feature: On the artist's show page, have each of the instruments listed link to the respective show page of the instrument (see below).
  • A dynamically generated show page for a single instrument that show its name and brand, as well as a list of artists that play that specific instrument.

  • An index page for all the instruments in your database.

    • A nice to have feature: On the index page, clicking on the name of the instrument would link the user to the instrument's show page.

After you have completed these deliverables, save and commit your code! Make sure everyone you're working with feels comfortable with the code and then, take a deep breath because we still have some work to do! ๐Ÿ˜ค

Creating the Associations

Your manager loves the work that you have done so far, but at the moment, there isn't a way for a user to log a relationship between an artist and an instrument.

We can accomplish this one of two ways:

  • Have a form that will take in an artist ID and an instrument ID and create the association between the two. Rather than having the user type in the IDs as numbers, consider implementing a select tag for a better user experience.
<form>
  <select name="artist_id">
    <!-- How would you dynamically generate <option/> elements for each of the artist instances? -->
  </select>

  <select name="instrument_id">
    <!-- How would you dynamically generate <option/> elements for each of the instrument instances? -->
  </select>
</form>

OR

  • Have a form in the artist's edit page with checkboxes of all the instruments. When the form is submitted, the artist being edited should be associated with the correct instruments.
<form>
  <!-- How would you dynamically generate checkboxes for each of the instrument instances -->
  <input type="checkbox" name="instruments[]" value="<%= instrument.id %>">
</form>

If you're using the checkbox method, think about what your params looks like after the form is submitted. What does the instruments[] imply about the information put into params? How can you use the information put into params to link the artist with the selected instruments? Also, is there a way you can dynamically check the boxes for the instruments that an artist plays?

If you were able to associate users with instruments, consider building out full CRUD for the Instrument model! Best of luck!

sinatra-jams-ii's People

Contributors

hyeokjungkim avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.