Method: Atreides::Base#to_param

Defined in:
lib/atreides/base/base.rb

#to_paramObject

Give a string identifying the model based on it’s properties. In order:

  • slug if it has a property slug

  • id-name if it has a property name

  • id-title if it has a property title

  • id otherwise

Returns:

  • A string describing an instance of a model



23
24
25
26
27
28
# File 'lib/atreides/base/base.rb', line 23

def to_param
  return slug.to_s if self.respond_to?(:slug) and !slug.blank?
  return "#{id}-#{name.to_s.parameterize}" if self.respond_to?(:name) and self.name?
  return "#{id}-#{title.to_s.parameterize}" if self.respond_to?(:title) and self.title?
  id.to_s
end