This repository has been archived by the owner. It is now read-only.

Creating instances of a STI model with unloadable :type should error? #203

kanzure opened this Issue May 30, 2012 · 0 comments


None yet
1 participant

kanzure commented May 30, 2012

Model.create should error when you pass in :type => "SomeOtherClass". For example, SomeOtherClass is a non-DM model. When later trying to load this particular instance from the db, there will be an error about "undefined method key for SomeOtherClass:Class". However, the error should probably occur during creation/saving?

class Model
  include DataMapper::Resource
  property :type, Discriminator

Suppose that someone is intending to use strings here for classes that don't exist. In this case, it would be better to use a string property to represent that. But if you're using Discriminator, you probably intend to reload the instance at some point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.