Displaying 1 result from an estimated 1 matches for "simple_task".
Did you mean:
simple_stack
2006 Feb 15
2
Polymorphic joins work one way, but not the other
...phic => true
#events table has attachable_type and attachable_id fields
end
class Task < ActiveRecord::Base
has_many :events, :as => :attachable
#tasks tables is nothing special
end
and now a unit test:
#there''s some fixtures above
def test_polymorphics
assert tasks(:simple_task).events << events(:simple_event_1)
assert tasks(:simple_task).events << events(:simple_event_2)
assert events(:simple_event_1).save!
assert tasks(:simple_task).save!
assert_equal 2, tasks(:simple_task).events.size
assert_equal "simple event 1",
tasks(:simp...