Commit 12c2c9b9 by Ivan Lan

update pasting_name

parent 280fa0c6
...@@ -33,9 +33,9 @@ module ActsAsPasting ...@@ -33,9 +33,9 @@ module ActsAsPasting
module ClassMethods module ClassMethods
def acts_as_pastable associations, prefix: '', **options def acts_as_pastable associations, prefix: '', **options
pasting_name = prefix.blank? ? :pastable_pastings : [prefix, 'pastable_pastings'].join('_').to_sym pasting_name = prefix.blank? ? "#{associations}_pastings" : [associations, prefix, 'pastings'].join('_').to_sym
has_many pasting_name, as: :pasteable, class_name: 'ActsAsPasting::Pasting' has_many(pasting_name, -> { where(type: prefix) }, as: :pasteable, class_name: 'ActsAsPasting::Pasting')
has_many associations, through: pasting_name, source: :pasted, **options has_many(associations, through: pasting_name, source: :pasted, **options)
end end
end end
end end
......
...@@ -202,9 +202,9 @@ module ActsAsPasting ...@@ -202,9 +202,9 @@ module ActsAsPasting
end end
def acts_as_pasted associations, prefix: '', **options def acts_as_pasted associations, prefix: '', **options
pasting_name = prefix.blank? ? :pastings : [prefix, 'pastings'].join('_').to_sym pasting_name = prefix.blank? ? "#{associations}_pastings" : [associations, prefix, 'pastings'].join('_').to_sym
has_many pasting_name, -> { where(type: prefix) }, class_name: 'ActsAsPasting::Pasting', as: :pasted has_many(pasting_name, -> { where(type: prefix) }, class_name: 'ActsAsPasting::Pasting', as: :pasted)
has_many associations, through: pasting_name, source: :pasteable, **options has_many(associations, through: pasting_name, source: :pasteable, **options)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment