Git Product home page Git Product logo

forms-and-basic-associations-rails-lab-sfo01-seng-ft-060120's Introduction

Forms And Basic Associations Rails Lab

Objectives

  1. Practice defining associations
  2. Practice building forms in ERB when working with nested models

A Song Library

In this lab, we're going to make a song library that helps record thoughts about various Songs. Our data model looks like this:

  • Artist
    • has a name attribute (String)
    • has many Songs
  • Song
    • has a title attribute (String)
    • belongs to an Artist
    • belongs to a Genre
    • has many Notes
  • Genre
    • has a name attribute (String)
    • has many songs
  • Note
    • has content attribute (String)
    • belongs to a Song

Instructions

  1. The base models, controllers, and seed data have been provided for you.
  2. You should create and migrate the database before starting to develop your solution.
  3. Seeding the database provides many Genres. You will add data about Artists, Notes, and Songs during the development of this application. The ArtistsController and SongsController have been built out so that you can do this.

First, connect the models by using the ActiveRecord association commands.

Next, update the minimal app/views/songs/new.html.erb.

This view should have a form that provides:

  • A text input box that sets the Song's title.
  • A text input box for the Artist.
  • A selection box for Genre. Users should be able to pick amongst existing genres only.
  • Several text input boxes to add notes to the song. These should have the IDs song_notes_1, song_notes_2, and so on for the specs to pass.

This is a challenging lab. Here are some hints:

  • You might need to search around for how to pass an array using strong_params!
  • It's easy to get confused between getting an Artist instance from a Song and an Artist's name. To help make your form work easier, solve the spec/models/song_spec.rb first. You can run a single spec by invoking it with e.g. rspec spec/models/song_spec.rb
  • Make use of the references below!
  • While we direct you to update new.html.erb, you're going to need to make changes in multiple models and the SongsController.

References

View Forms And Basic Associations Rails Lab on Learn.co and start learning to code for free.

forms-and-basic-associations-rails-lab-sfo01-seng-ft-060120's People

Contributors

maxwellbenton avatar queerviolet avatar sgharms avatar ipc103 avatar pletcher avatar danielseehausen avatar mendelb avatar annjohn avatar genericlady avatar jmburges avatar drakeltheryuujin avatar rrcobb avatar aviflombaum avatar lkwlala avatar sdcrouse avatar

Watchers

James Cloos avatar Kaitlin Vignali avatar  avatar Victoria Thevenot avatar Bernard Mordan avatar Otha avatar raza jafri avatar  avatar Joe Cardarelli avatar The Learn Team avatar  avatar Ben Oren avatar Matt avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Dominique De León avatar  avatar Lisa Jiang avatar Vicki Aubin avatar  avatar  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.