Skip to content

Commit 502c624

Browse files
committed
Update trackable association to optional
1 parent 73978cf commit 502c624

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/public_activity/orm/active_record/activity.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@ class Activity < ::ActiveRecord::Base
2424
self.table_name = PublicActivity.config.table_name
2525
self.abstract_class = true
2626

27-
# Define polymorphic association to the parent
28-
belongs_to :trackable, polymorphic: true
29-
3027
case ::ActiveRecord::VERSION::MAJOR
3128
when 5
3229
with_options(required: false) do
30+
# Define polymorphic association to the parent
31+
belongs_to :trackable, polymorphic: true
3332
# Define ownership to a resource responsible for this activity
3433
belongs_to :owner, polymorphic: true
3534
# Define ownership to a resource targeted by this activity
3635
belongs_to :recipient, polymorphic: true
3736
end
3837
when 6..7
3938
with_options(optional: true) do
39+
# Define polymorphic association to the parent
40+
belongs_to :trackable, polymorphic: true
4041
# Define ownership to a resource responsible for this activity
4142
belongs_to :owner, polymorphic: true
4243
# Define ownership to a resource targeted by this activity

0 commit comments

Comments
 (0)