-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Her-35-add-product_id-and-product_type-to-order #29
Her-35-add-product_id-and-product_type-to-order #29
Conversation
before event model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just forgot an "s" that would cause an undefined error.
app/models/order.rb
Outdated
@@ -1,6 +1,7 @@ | |||
class Order < ApplicationRecord | |||
belongs_to :kit | |||
belongs_to :user | |||
belong_to :product, polymorphic: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
belongs_to :product, polymorphic: true
Forgot the s.
I am not really sure what is going on with the test check. Maybe we will have to ask Raquel. |
bd3c2e9
to
41611f2
Compare
Now you need to get your tests to match your changes. Let me know if you need help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few changes. Also, there are a bunch of minor corrections in your checks that need to be made, spaces mostly. I updated the brakeman in the last merge with main. So if you update your working branch with the latest main and run bundle install, then your brakeman will update automatically. Let me if you have problems, we may be able to get together on the zoom channel so you can share your screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to address the errors in your PR!
app/models/order.rb
Outdated
@@ -1,6 +1,7 @@ | |||
class Order < ApplicationRecord | |||
belongs_to :kit | |||
#belongs_to :kit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this instead of commenting out
#belongs_to :kit |
def up | ||
# define the changes kit id into product id | ||
Order.where.not(kit_id: nil).find_each do |order| | ||
order.update(product_id: order.kit_id, product_type: "Kit") | ||
end | ||
remove_column :orders, :kit_id, :integer | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we do not expect existing Order records as the app is not yet deployed, lets not include an update script in our migration.
def up | |
# define the changes kit id into product id | |
Order.where.not(kit_id: nil).find_each do |order| | |
order.update(product_id: order.kit_id, product_type: "Kit") | |
end | |
remove_column :orders, :kit_id, :integer | |
end | |
def change | |
remove_column :orders, :kit_id, :integer | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…-and-product_type-to-order
…t_type-to-order' into HER-35-add-product_id-and-product_type-to-order
HER-35 : Add :product_id and :product_type to Order
Issue
https://raquelanaroman.atlassian.net/browse/HER-35
Description
We would like to be able to associate an Order with multiple types of Products, not just Kits, so we would like to add a polymorphic relationship to the orders model
Acceptance Criteria
add_reference to orders for product that is polymorphic
Changes
generate migration to add product to order
updated Kit model, donation model, order model with some validation
updated orders controller
Review Checklist