Sha256: 05f7ad415207d916582641d2a6ec446e44a160d1dea45096f3ad7d96e8840266
Contents?: true
Size: 808 Bytes
Versions: 13
Compression:
Stored size: 808 Bytes
Contents
module Concerns module Model module BaseListItem extend ActiveSupport::Concern included do belongs_to :list belongs_to :thing, polymorphic: true validates :list_id, presence: true validates :thing_type, presence: true validates :thing_id, presence: true #pusherable "#{Rails.env}_channel" def thing=(thing) thing.save if thing.new_record? self.thing_type = thing.class.name; self.thing_id = thing.id if self.respond_to?(:list_item_id) && self.list.present? self.list_item ||= self.list.items.find_or_create_by_thing_type_and_thing_id(thing_type, thing_id) end thing end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems