-
Notifications
You must be signed in to change notification settings - Fork 63
STI, and Subject Type #10
Copy link
Copy link
Open
Description
I've got an Asset model, extending this model are Photo, and Plan. When I run fires :on => :create, the subject should be of either type Photo, or Plan. However, it's setting it's type to Asset. Is there a way around this?
photo.rb
class Photo < Asset
# Timeline Events
fires :new_asset, :on => :create,
:actor => :actor,
:secondary_subject => :project
end
plan.rb
class Plan < Asset
# Timeline Events
fires :new_asset, :on => :create,
:actor => :actor,
:secondary_subject => :project
end
asset.rb
class Asset < ActiveRecord::Base
end
Record of Asset, you can see the type here is Photo:
+------+----------------------------------------------+------------+--------------------------+-----------+-------+-------------------------+-------------------------+
| id | source | project_id | content_type | file_size | type | created_at | updated_at |
+------+----------------------------------------------+------------+--------------------------+-----------+-------+-------------------------+-------------------------+
| 1140 | /uploads/photo/source/1140/around_ennis5.jpg | 1 | application/octet-stream | 2150343 | Photo | 2011-09-22 17:23:22 UTC | 2011-09-22 17:23:22 UTC |
+------+------------+--------------+------------+------------------------+------------+----------+----------------------+-------------------------+-------------------------+
Record of TimelineEvent. You see the type here is Asset. They're mismatched:
+------+------------+--------------+------------+------------------------+------------+----------+----------------------+-------------------------+-------------------------+
| id | event_type | subject_type | actor_type | secondary_subject_type | subject_id | actor_id | secondary_subject_id | created_at | updated_at |
+------+----------------------------------------------+------------+--------------+-----------+-------+-------------------------+-------------------------+
| 1128 | new_asset | Asset | User | Project | 1140 | 1 | 1 | 2011-09-22 17:23:22 UTC | 2011-09-22 17:23:22 UTC |
+------+----------------------------------------------+------------+--------------+-----------+-------+-------------------------+-------------------------+
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels