app/models/effective/page.rb in effective_pages-3.7.0 vs app/models/effective/page.rb in effective_pages-3.7.1

- old
+ new

@@ -43,10 +43,11 @@ has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page', foreign_key: :menu_parent_id, inverse_of: :menu_parent acts_as_role_restricted + acts_as_paginable if respond_to?(:acts_as_paginable) # Effective Resources acts_as_slugged acts_as_tagged has_many_rich_texts log_changes if respond_to?(:log_changes) @@ -106,17 +107,9 @@ scope :menu_parents, -> { where(menu: true).where(id: Effective::Page.select('menu_parent_id')).menu_sorted } scope :menu_children, -> { where(menu: true).where.not(menu_parent_id: nil).menu_sorted } scope :for_sitemap, -> { published.where(menu: false).or(published.where(menu: true).where.not(id: menu_root_with_children)) - } - - # Maybe change paginate to be an isolated function instead of a scope, so we can use it with PgSearch::Document when doing a whole app search? - scope :paginate, -> (page: nil, per_page: nil) { - page = (page || 1).to_i - offset = [(page - 1), 0].max * per_page - - limit(per_page).offset(offset) } before_validation(if: -> { menu? && menu_position.blank? }) do self.menu_position = (self.class.where(menu_parent: menu_parent).maximum(:menu_position) || -1) + 1 end