Skip to content

Cheer time! When I say "Poly", you say "Morphic", "Gon", "Vore", "Glot" or whatever your receiver returns!

Notifications You must be signed in to change notification settings

andie5/assignment_polymorphism

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project: assignment_polymoprhism

Practice polymorphism

Andrea A

To Get Going

  • run rake db:create

  • run rake db:migrate

  • run rake db:seed

  • run rails s

  • In the browser run localhost:3000

The Viking Store e-commerce application for Viking Commerce Inc from the Viking Code School

Polymorphism relationship

Address can belong to many things

  • Person
  • Off Licence
  • Dentist

Description of model

In each model - address_type as well as address_id Each model will be 'addresssable'

##Tests

simple association methods

Company.first.addresses Person.first.addresses Address.first.addressable Address.second.addressable

re-assigning and adding to associations

Company.first.addresses.build(:street_address => Faker::Address.street_address, :address_line_2 => Faker::Address.community, :postcode => Faker::Address.zip_code, :addressable_id => "Company", :addressable_type => Company.last.id) Company.second.addresses << Address.second Person.second.addresses << Address.third Company.second.address_ids # ids

de-associating

Company.second.addresses.delete(Address.second)

About

Cheer time! When I say "Poly", you say "Morphic", "Gon", "Vore", "Glot" or whatever your receiver returns!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Ruby 78.9%
  • HTML 15.2%
  • JavaScript 3.1%
  • CSS 2.3%
  • CoffeeScript 0.5%