Git Product home page Git Product logo

456_def's Introduction

Basic Associations Assessment

Google Form Q+As | Don't forget the Q+As!!!

Complete the questions at this Google form and sumbit!

Build a raw HTML Rails form given a params hash

Here is a ruby hash that represents the params submitted by a form.

{
  :utf8 => '✓',
  :authenticity_token => '401b09eab3c013d4ca54922bb802bec8fd5318192b0a75f201d8b3727429080fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f5a65ed1',
  :user => {
    :username => 'foobar1234',
    :email => '[email protected]',
    :password => 'password1234',
    :password_confirm => 'password1234'
  }
}

Given the hash above, complete the following:

  • open up this README file in your text editor.
  • write an HTML code block under this section (under where it says "Your HTML form here:")
  • the block must contain a raw HTML form (NO form_for NO form_tag or anything but HTML)
  • the form should be setup so that when submitted:
    • it nests attributes exactly like the hash above
    • password inputs are used where needed
    • sensitive data must not be displayed to the user
    • unnecessary data must not be display to the user
  • some inputs will require values to be set
  • other inputs must be left blank for the user to provide a value
  • assume you are working in a raw HTML file without ERB
  • don't forget the default functionality of HTML input types!

Your HTML form here:

<form action='submit/path' method='post' >
  <input type='hidden' name='authenticity_token' value='401b09eab3c013d4ca54922bb802bec8fd5318192b0a75f201d8b3727429080fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f5a65ed1'>
  <input type="hidden" name="utf8" value="" />

  <input type='text' name='user[username]'>
  <input type='email' name='user[email]'>
  <input type='password' name='user[password]'>
  <input type='password' name='user[password_confirm]'>

  <input type='submit'>
</form>

Rails Associations

Setup

  1. Install the local gems with bundler

    $ bundle install
  2. Check that RSpec is working

    $ bundle exec rspec
  3. Make sure guard is working

    $ bundle exec guard
  4. Once everything is set and you run guard or rspec, you will most likely see errors that:

    • the schema doesn't exist
    • a model doesn't exist

Follow these errors to create/run the necessary commands to set up your database and create the models that the tests expect!

Schema

You will need to create a schema with a structure and relationships that make the below associations possible.

Think about

  • what tables you need
  • what foreign keys you need
  • what tables get the foreign keys

This is for you! Don't make this pretty or post it anywhere for grading. This is a step for you to think about how your data model is structured before you begin implementing.

Migrations

Once you have your schema you will need to create the migrations that setup the database.

Generating a model automatically creates a migration file for that model's table. NOTE: Make sure to use the option of --no-test-framework. This ensures that test files that will conflict with existing ones will NOT be created.

$ rails g model MyModel --no-test-framework

Populate your migrations with the schema you created above and get associating!

Models

Create Rails models that have the following attributes and associations:

  1. Employee

    • attributes:
      • first_name:string
      • last_name:string
      • email:string
    • associations:
      • has many teams
        • teams of which the employee is a member
      • has many progress reports
        • progress reports the employee wrote about a team
      • has many owned teams
        • teams of which the employee is the owner
  2. Team

    • attributes:
      • name:string
    • associations:
      • belongs to owner
        • employee that owns the team
      • has many members
        • employees that are members of the team
      • has many progress_reports
        • progress reports written about this team
  3. Progress Report

    • attributes:
      • body:text
    • associations:
      • belongs to author
        • employee that wrote the progress report
      • belongs to team
        • team that the progress report is written about

Seeding

Create a barebones seeds file that populates the database with records in all tables.

The seeds should generate records that use all of the above associations where appropriate.

The seeds should be minimal and only to help you verify your associations work.

The Faker gem has been provided for you to make this process easier! Focus on making the associations work and make sure they return what is expected!

Good Luck!

456_def's People

Contributors

jmazzy avatar eriktrautman avatar

Watchers

James Cloos 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.