app/models/page.rb in refinerycms-pages-0.9.9.21 vs app/models/page.rb in refinerycms-pages-0.9.9.22
- old
+ new
@@ -45,10 +45,11 @@
:created_at, :updated_at, :page_id
attr_accessor :locale # to hold temporarily
validates :title, :presence => true
+ # Docs for acts_as_nested_set https://github.com/collectiveidea/awesome_nested_set
acts_as_nested_set :dependent => :destroy # rather than :delete_all
# Docs for friendly_id http://github.com/norman/friendly_id
has_friendly_id :title, :use_slug => true,
:default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
@@ -72,29 +73,29 @@
before_destroy :deletable?
after_save :reposition_parts!, :invalidate_child_cached_url, :expire_page_caching
after_destroy :expire_page_caching
# Wrap up the logic of finding the pages based on the translations table.
- scope :with_globalize, lambda {|conditions|
- if defined?(::Page::Translation)
- conditions = {:locale => Globalize.locale}.merge(conditions || {})
- where(:id => ::Page::Translation.where(conditions).select('page_id AS id')).includes(:translations)
- else
- where(conditions)
+ if defined?(::Page::Translation)
+ def self.with_globalize(conditions = {})
+ conditions = {:locale => Globalize.locale}.merge(conditions)
+ where(:id => ::Page::Translation.where(conditions).select('page_id AS id')).includes(:children, :slugs)
end
- }
+ else
+ def self.with_globalize(conditions = {})
+ where(conditions).includes(:children, :slugs)
+ end
+ end
scope :live, where(:draft => false)
- scope :by_title, lambda {|t| with_globalize(:title => t)}
+ scope :by_title, proc {|t| with_globalize(:title => t)}
# Shows all pages with :show_in_menu set to true, but it also
# rejects any page that has not been translated to the current locale.
# This works using a query against the translated content first and then
# using all of the page_ids we further filter against this model's table.
- scope :in_menu, lambda {
- where(:show_in_menu => true).with_globalize({})
- }
+ scope :in_menu, proc { where(:show_in_menu => true).with_globalize }
# when a dialog pops up to link to a page, how many pages per page should there be
PAGES_PER_DIALOG = 14
# when listing pages out in the admin area, how many pages should show per page
@@ -288,10 +289,11 @@
def expire_page_caching
begin
Rails.cache.delete_matched(/.*pages.*/)
rescue NotImplementedError
- warn "**** [REFINERY] The cache store you are using is not compatible with Rails.cache#delete_matched so please disable caching to ensure proper operation. ***"
+ Rails.cache.clear
+ warn "**** [REFINERY] The cache store you are using is not compatible with Rails.cache#delete_matched - clearing entire cache instead ***"
end
end
end
# Accessor method to get a page part from a page.