Class: Binda::Category

Inherits:
ApplicationRecord show all
Extended by:
FriendlyId
Defined in:
app/models/binda/category.rb

Instance Method Summary collapse

Instance Method Details

#default_slugObject

Set slug name

It generates 4 possible slugs before falling back to FriendlyId default behaviour



28
29
30
31
32
33
# File 'app/models/binda/category.rb', line 28

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

#should_generate_new_friendly_id?Boolean

Friendly id preference on slug generation

Method inherited from friendly id



21
22
23
# File 'app/models/binda/category.rb', line 21

def should_generate_new_friendly_id?
  slug.blank? || name_changed?
end