Giter Club home page Giter Club logo

rails_house's Introduction

Rails House

By the end of this project, each Person will live in a house and each House will have an address.

Phase 1 - New Project

  1. Run bundle exec rails db:create
  2. If there are migrations, run bundle exec rails db:migrate
  3. If there are seeds, run bundle exec rails db:seed

Phase 2: Create Models and Migrations

  • Create a Person model and a people table (each Person should have a name and a house_id)
    • Create and run a Migration for each model. (Refer to the Migration Reading if you need a reminder!)
    • Create a file called model_name.rb in /app/models/ for each model.
    • Validate the presence of each of the attributes that model can have.
  • Create a House model and a houses table (each House should have an address).

Phase 3: Create associations

  • Create Associations for Houses with People such that Houses can have many #residents and each Person belongs to a #house. (Refer to the readings for belongs_to and has_many.)
    • This relies on you specifying the correct primary_key, foreign_key, and class_name; otherwise, when you call House.residents, Rails will assume you are following conventions and look for a residents table rather than a people table!

Phase 4: Try it out!

  • Use the rails console to create some data and run some basic queries.

  • You should be able to run the following.

house = House.new(address: '308 Negra Arroyo Lane')
person = Person.new(name: 'Walter White', house_id: house.id)

house.save!
person.save!

rails_house's People

Contributors

combatd avatar dependabot[bot] 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.