Module: Permalink::Builder

Extended by:
ActiveSupport::Concern
Included in:
LinkGroup, PaymentMethod, Product, ProductGroup, ShipmentCarrier, ShippingZone
Defined in:
lib/nimbleshop/permalink/builder.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/nimbleshop/permalink/builder.rb', line 33

def set_permalink
  return if self.name.blank? && permalink_options[:allow_nil]
  permalink = self.name.parameterize
  counter = 2

  while self.class.exists?(permalink: permalink) do
    permalink = "#{permalink}-#{counter}"
    counter = counter + 1
  end

  self.permalink ||= permalink
end

#to_paramObject



29
30
31
# File 'lib/nimbleshop/permalink/builder.rb', line 29

def to_param
  self.permalink
end