<commit_before>require 'stringex'

module Recipe
  class Category < ActiveRecord::Base
    if Recipe.config.engine_routing
      include Recipe::Engine.routes.url_helpers
    else
      include Rails.application.routes.url_helpers
    end

    self.table_name = "recipe_categories"

    attr_accessible                   :image,
                                      :order,
                                      :text,
                                      :url,
                                      :name,
                                      :item_ids

    has_many                          :categorisations
    has_many                          :items, :through => :categorisations
    accepts_nested_attributes_for     :categorisations

    has_attached_file                 :image,
                                      :styles => {
                                        :main => Recipe.config.main_item_image_size,
                                        :secondary => Recipe.config.secondary_item_image_size,
                                        :thumb => Recipe.config.item_thumb_size
                                      }

    validates_presence_of             :order,
                                      :text,
                                      :name

    validates_uniqueness_of           :name

    default_scope                     :order => '`order` ASC'
    acts_as_url                       :name

    def get_canonical_url
      recipe_category_path(self)
    end

    def to_param
      url
    end

    def to_s
      name
    end
  end
end
<commit_msg>order on the has many<commit_after>require 'stringex'

module Recipe
  class Category < ActiveRecord::Base
    if Recipe.config.engine_routing
      include Recipe::Engine.routes.url_helpers
    else
      include Rails.application.routes.url_helpers
    end

    self.table_name = "recipe_categories"

    attr_accessible                   :image,
                                      :order,
                                      :text,
                                      :url,
                                      :name,
                                      :item_ids

    has_many                          :categorisations
    has_many                          :items, :through => :categorisations, :order => '`order` ASC'
    accepts_nested_attributes_for     :categorisations

    has_attached_file                 :image,
                                      :styles => {
                                        :main => Recipe.config.main_item_image_size,
                                        :secondary => Recipe.config.secondary_item_image_size,
                                        :thumb => Recipe.config.item_thumb_size
                                      }

    validates_presence_of             :order,
                                      :text,
                                      :name

    validates_uniqueness_of           :name

    default_scope                     :order => '`order` ASC'
    acts_as_url                       :name

    def get_canonical_url
      recipe_category_path(self)
    end

    def to_param
      url
    end

    def to_s
      name
    end
  end
end

{'fraction_non_alphanumeric': 0.05235275786849486, 'fraction_numerical': 0.0, 'mean_word_length': 0.9325707405177603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7194255', 'n_tokens_mistral': 772, 'n_tokens_neox': 732, 'n_words': 141}