<commit_before>module PlazrStore
  class FeedbackProduct < ActiveRecord::Base
    ## Relations ##
    # belongs_to :user TODO metodo que chama api
    belongs_to :product
    belongs_to :order

    after_save :update_product_rating

    validates :rating, presence: true
    validates :order_id, uniqueness: { scope: :product_id, message: "You already have reviewed this item in this order" }
    
    ## Attributes ##
    attr_accessible :comment, :rating, :product, :order

    protected

      def update_product_rating
        self.product.update_rating unless self.rating.nil?
      end
  end<commit_msg>added method owner to feeback_product<commit_after>module PlazrStore
  class FeedbackProduct < ActiveRecord::Base
    ## Relations ##
    # belongs_to :user TODO metodo que chama api
    belongs_to :product
    belongs_to :order

    after_save :update_product_rating

    validates :rating, presence: true
    validates :order_id, uniqueness: { scope: :product_id, message: "You already have reviewed this item in this order" }
    
    ## Attributes ##
    attr_accessible :comment, :rating, :product, :order

    ## Instance Methods ##
    def owner
      self.order.user
    end

    protected

      def update_product_rating
        self.product.update_rating unless self.rating.nil?
      end
  end
{'fraction_non_alphanumeric': 0.0730593607305936, 'fraction_numerical': 0.0, 'mean_word_length': 3.2973856209150325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2638493', 'n_tokens_mistral': 385, 'n_tokens_neox': 370, 'n_words': 113}