Sha256: 23a0b02da71a8d850a428835077bd8ce58e21eff544bc7d1f08c57cb1185991e
Contents?: true
Size: 776 Bytes
Versions: 1
Compression:
Stored size: 776 Bytes
Contents
module CmPageBuilder::Rails class Page < ApplicationRecord belongs_to :container, polymorphic: true has_many :page_components, dependent: :destroy accepts_nested_attributes_for :page_components, allow_destroy: true def save_content(component_json) components = JSON.parse component_json deleted_components = self.page_components.where.not( id: components.map {|c| c["id"] } ) deleted_components.delete_all components.each do |component| self.page_components .find_or_initialize_by(id: component["id"]) .update!( content: component["content"], position: component["position"], component_type: component["componentType"] ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cm_page_builder-rails-0.1.0 | app/models/cm_page_builder/rails/page.rb |