Sha256: 9aff0c296be65f0a15779c9d52bbff955906f6bc11c18b6bacbe8d30bb3c2858
Contents?: true
Size: 684 Bytes
Versions: 4
Compression:
Stored size: 684 Bytes
Contents
module Binda class Category < ApplicationRecord # Associations belongs_to :structure has_and_belongs_to_many :components # Validations validates :name, presence: true # Slug extend FriendlyId friendly_id :default_slug, use: [:slugged, :finders] # CUSTOM METHODS # -------------- # https://github.com/norman/friendly_id/issues/436 def should_generate_new_friendly_id? slug.blank? || name_changed? end def default_slug [ "#{ self.structure.name }-#{ self.name }", "#{ self.structure.name }-#{ self.name }-1", "#{ self.structure.name }-#{ self.name }-2", "#{ self.structure.name }-#{ self.name }-3" ] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
binda-0.0.6 | app/models/binda/category.rb |
binda-0.0.5 | app/models/binda/category.rb |
binda-0.0.3 | app/models/binda/category.rb |
binda-0.0.2 | app/models/binda/category.rb |