Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STI, and Subject Type #10

Open
codezomb opened this issue Sep 22, 2011 · 1 comment
Open

STI, and Subject Type #10

codezomb opened this issue Sep 22, 2011 · 1 comment

Comments

@codezomb
Copy link

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 |
+------+----------------------------------------------+------------+--------------+-----------+-------+-------------------------+-------------------------+
@xurde
Copy link

xurde commented Apr 30, 2013

Same issue going on here.
Found any solution for STI?

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants