Module: Alchemy::Page::PageNaming

Extended by:
ActiveSupport::Concern
Includes:
NameConversions
Included in:
Alchemy::Page
Defined in:
app/models/alchemy/page/page_naming.rb

Constant Summary collapse

RESERVED_URLNAMES =
%w[admin messages new]

Instance Method Summary collapse

Methods included from NameConversions

#convert_to_humanized_name, #convert_to_urlname

Instance Method Details

#renamed?Boolean

Returns true if name or urlname has changed.

Returns:

  • (Boolean)


34
35
36
# File 'app/models/alchemy/page/page_naming.rb', line 34

def renamed?
  name_changed? || urlname_changed?
end

#slugObject

Returns always the last part of a urlname path



49
50
51
# File 'app/models/alchemy/page/page_naming.rb', line 49

def slug
  urlname.to_s.split("/").last
end

#update_urlname!Object

Makes a slug of all ancestors urlnames including mine and delimit them be slash. So the whole path is stored as urlname in the database.



40
41
42
43
44
45
46
# File 'app/models/alchemy/page/page_naming.rb', line 40

def update_urlname!
  new_urlname = nested_url_name
  if urlname != new_urlname
    legacy_urls.create(urlname: urlname)
    update_column(:urlname, new_urlname)
  end
end