Skip to content

sellect/associations_challenge_8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##alt text ###Associations Code Challenge

This challenge is to assess your ability to write concise and meaningful data relationships using Rails ActiveRecord. Model structure is the focus of this exercise, so views and controllers are not required. Example outputs are at the bottom.


######INSTRUCTIONS

Fork this repo and complete the tasks below. Once complete please submit a pull request.


######TASK #1

Create 3 models:

  • Order
  • Customer
  • Note

Column requirements:

  • Order has a unique identifier column number that consists of the letter R followed by 9 random numbers, generated upon order creation
  • Note has a column message
  • Customer has a unique column email

######TASK #2

Design associations such that:

  • Notes can be associated with orders
  • Notes can be associated with customers
  • Order is associated to one customer
  • Customer can be associated with multiple orders

######TASK #3

Design your model associations to retrieve a customer's notes ( which includes notes associated with the customer and the notes associated with the customer's orders )

####EXAMPLE OUTPUTS

retrieve customer's orders

customer = Customer.first
customer.orders

# => [#<Order id: 1 ... >, #<Order id: 2 ... >]

retrieve customer's notes

customer = Customer.first
customer.notes

# => [#<Note id: 1 ... >, #<Note id: 2 ... >]

retrieve order's notes

order = Order.first
order.notes

# => [#<Note id: 1 ... >, #<Note id: 2 ... >]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published