Created
April 8, 2011 11:35
-
-
Save sheldonbaker/909677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Video < ActiveRecord::Base | |
inherits_from :item | |
end | |
class Article < ActiveRecord::Base | |
inherits_from :item | |
end | |
class Item < ActiveRecord::Base | |
has_many :responses | |
end | |
class Response < ActiveRecord::Base | |
belongs_to :item | |
validates_presence_of :item_id | |
end | |
# in console: | |
# | |
# saving a new video item (maybe at items/video/new) | |
v = Video.new | |
v.save # true | |
# saving a response to that (video) item | |
r = Response.new | |
r.item = Item.find(1) #causes error | |
# error: | |
# | |
# ActiveRecord::AssociationTypeMismatch: Item(#2157741480) expected, got Video(#2155124540) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment