Last active
August 29, 2015 13:58
-
-
Save WaKeMaTTa/10111451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LineItem < ActiveRecord::Base | |
belongs_to :order | |
belongs_to :product | |
validates :product_id, :quantity, presence: true | |
validates :quantity, numericality: { only_integer: true } | |
before_save :set_price_to_products | |
private | |
def set_price_to_products | |
self.price = self.product.price | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment