<commit_before>module Refinery
  module Products
    class Category < Refinery::Core::BaseModel
      extend FriendlyId

      translates :title, :slug

      friendly_id :friendly_id_source, :use => [:slugged, :globalize]

      validates :title, :presence => true, :uniqueness => true

      # To enable admin searching, add acts_as_indexed on searchable fields, for example:
      #
      #   acts_as_indexed :fields => [:title]

    end
  end
end<commit_msg>Update category model to work with friendly id<commit_after>module Refinery
  module Products
    class Category < Refinery::Core::BaseModel
      extend FriendlyId

      translates :title, :slug

      friendly_id :friendly_id_source, :use => [:slugged, :globalize]

      validates :title, :presence => true, :uniqueness => true

      acts_as_indexed :fields => [:title]

      # If title changes tell friendly_id to regenerate slug when
      # saving record
      def should_generate_new_friendly_id?
        title_changed?
      end

      def friendly_id_source
        title
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.07635009310986965, 'fraction_numerical': 0.0, 'mean_word_length': 2.9667896678966788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '2544123', 'n_tokens_mistral': 321, 'n_tokens_neox': 311, 'n_words': 94}