app/models/spina/structure_item.rb in spina-0.12.0 vs app/models/spina/structure_item.rb in spina-1.0.0
- old
+ new
@@ -6,9 +6,11 @@
belongs_to :structure, optional: true
has_many :structure_parts, dependent: :destroy
scope :sorted_by_structure, -> { order(:position) }
+ after_save -> { structure_parts.each(&:save) }
+
validates_presence_of :position
accepts_nested_attributes_for :structure_parts, allow_destroy: true
alias_attribute :parts, :structure_parts