Sha256: 6eb49504b0afca9f6e2a805386d20c6b5c25190b91356cd40c17a5d65a75d283
Contents?: true
Size: 664 Bytes
Versions: 15
Compression:
Stored size: 664 Bytes
Contents
require 'acts_as_list' module Fe class PageElement < ApplicationRecord self.table_name = self.table_name.sub('fe_', Fe.table_name_prefix) acts_as_list scope: :page_id belongs_to :page, touch: true belongs_to :element after_save :save_element before_create :set_position after_destroy :rebuild_page_all_element_ids def set_position self.position ||= (page.page_elements.last.try(:position) + 1) || page.elements.last.try(:position) || 0 end # need conditional callbacks run def save_element element.save! end def rebuild_page_all_element_ids page.rebuild_all_element_ids end end end
Version data entries
15 entries across 15 versions & 1 rubygems