<commit_before>module CaseStudy
  class Taxonomy < ActiveRecord::Base
    belongs_to :case_study, :class_name => 'CaseStudy::Item'
    belongs_to :taxonomable, polymorphic: true

    attr_accessible :order, :case_study_id

    validates :case_study_id, :presence => true, :uniqueness => { :scope => :taxonomable_id }

    default_scope :order => '`case_study_taxonomies`.`order` ASC'

    scope :to_categories, -> { where arel_table[:taxonomable_type].eq('CaseStudy::Category') }
    scope :to_case_studies, -> { where arel_table[:case_study_id].not_eq(nil) }
    scope :to_tags, -> { where arel_table[:taxonomable_type].eq('CaseStudy::Tag') }
  end
end<commit_msg>validates based on type and id<commit_after>module CaseStudy
  class Taxonomy < ActiveRecord::Base
    belongs_to :case_study, :class_name => 'CaseStudy::Item'
    belongs_to :taxonomable, polymorphic: true

    attr_accessible :order, :case_study_id

    validates :case_study_id, :presence => true, :uniqueness => { :scope => [:taxonomable_id, :taxonomable_type] }

    default_scope :order => '`case_study_taxonomies`.`order` ASC'

    scope :to_categories, -> { where arel_table[:taxonomable_type].eq('CaseStudy::Category') }
    scope :to_case_studies, -> { where arel_table[:case_study_id].not_eq(nil) }
    scope :to_tags, -> { where arel_table[:taxonomable_type].eq('CaseStudy::Tag') }
  end
end
{'fraction_non_alphanumeric': 0.13450292397660818, 'fraction_numerical': 0.0, 'mean_word_length': 5.367441860465116, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2955257', 'n_tokens_mistral': 496, 'n_tokens_neox': 463, 'n_words': 87}