app/models/alchemy/page.rb in alchemy_cms-3.0.1 vs app/models/alchemy/page.rb in alchemy_cms-3.0.2
- old
+ new
@@ -82,10 +82,11 @@
attr_accessor :do_not_validate_language
before_save :set_language_code, if: -> { language.present? }, unless: :systempage?
before_save :set_restrictions_to_child_pages, if: :restricted_changed?, unless: :systempage?
before_save :inherit_restricted_status, if: -> { parent && parent.restricted? }, unless: :systempage?
+ before_save :update_published_at, if: -> { public && read_attribute(:published_at).nil? }, unless: :systempage?
before_create :set_language_from_parent_or_default, if: -> { language_id.blank? }, unless: :systempage?
after_update :create_legacy_url, if: :urlname_changed?, unless: :redirects_to_external?
# Concerns
include Alchemy::Page::PageScopes
@@ -102,17 +103,17 @@
alias_method :rootpage, :root
# Used to store the current page previewed in the edit page template.
#
def current_preview=(page)
- Thread.current[:alchemy_current_preview] = page
+ RequestStore.store[:alchemy_current_preview] = page
end
# Returns the current page previewed in the edit page template.
#
def current_preview
- Thread.current[:alchemy_current_preview]
+ RequestStore.store[:alchemy_current_preview]
end
# @return the language root page for given language id.
# @param language_id [Fixnum]
#
@@ -388,9 +389,13 @@
end
# Stores the old urlname in a LegacyPageUrl
def create_legacy_url
legacy_urls.find_or_create_by(urlname: urlname_was)
+ end
+
+ def update_published_at
+ self.published_at = Time.now
end
end
end