lib/drafting/base_class_methods.rb in drafting-0.4.2 vs lib/drafting/base_class_methods.rb in drafting-0.5.0
- old
+ new
@@ -13,14 +13,22 @@
raise ArgumentError unless parent_class
unless parent_class.method_defined? :drafts
parent_class.class_eval do
def drafts(user)
- Draft.where(user: user, parent: self)
+ Draft.where(
+ user: user,
+ user_type: user.try(:class).try(:name),
+ parent: self
+ )
end
def self.child_drafts(user)
- Draft.where(user: user, parent_type: self.base_class.name)
+ Draft.where(
+ user: user,
+ user_type: user.try(:class).try(:name),
+ parent_type: self.base_class.name
+ )
end
end
end
self.draft_parent = options[:parent]