module Decidim::Initiatives::InitiativeSlug

Public Instance Methods

id_from_slug(slug) click to toggle source
# File lib/decidim/initiatives/initiative_slug.rb, line 10
def id_from_slug(slug)
  return slug if /\A\d+\Z/.match?(slug)

  slug[2..-1] if slug.present?
end
slug_from_id(id) click to toggle source
# File lib/decidim/initiatives/initiative_slug.rb, line 6
def slug_from_id(id)
  "i-#{id}"
end