Sha256: de1e2ac63596db00f0ca03363f591cf597f2c004f3d8cfc9aa727a454d30e24a
Contents?: true
Size: 847 Bytes
Versions: 6
Compression:
Stored size: 847 Bytes
Contents
require 'active_support/inflector' module Rewritten module Document include ActiveSupport::Inflector def path plural = ActiveSupport::Inflector.pluralize(self.class.to_s) resources = ActiveSupport::Inflector.underscore(plural) "/#{resources}/#{id}" end def rewritten_url return '' unless persisted? Rewritten.get_current_translation(path) end def rewritten_url=(new_url) if !new_url.nil? && new_url != '' && new_url != rewritten_url Rewritten.add_translation(new_url, path) end end def rewritten_urls return [] unless persisted? Rewritten.get_all_translations(path) end def rewritten_url? Rewritten.exist_translation_for?(path) end def remove_rewritten_urls Rewritten.remove_all_translations(path) end end end
Version data entries
6 entries across 6 versions & 1 rubygems