module Shoppe::ModelExtension
Public Class Methods
included(base)
click to toggle source
# File lib/shoppe/model_extension.rb, line 4 def self.included(base) base.extend ClassMethods base.after_save do if @pending_attachments @pending_attachments.each do |pa| old_attachments = self.attachments.where(:role => pa[:role]).pluck(:id) self.attachments.create(:file => pa[:file], :role => pa[:role]) self.attachments.where(:id => old_attachments).destroy_all end @pending_attachments = nil end end end