Skip to content
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

Validate presence of product on a Variant #2020

Merged
merged 1 commit into from
Jun 21, 2017

Conversation

jhawthorn
Copy link
Contributor

It might also make sense to add a DB constraint.

Fixes #2011

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will do the trick, but I think we should consider to switch to Rails' default behavior of belongs_to bit by bit and then finally turn it on again.

Also 👍 for database constraints

@@ -61,6 +61,7 @@ class Variant < Spree::Base

validate :check_price

validates :product, presence: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we instead use optional: false on the belongs_to :product above?

Copy link
Contributor

@mamhoff mamhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add the constraint in another PR.

@gmacdougall gmacdougall merged commit ca707c4 into solidusio:master Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants