-
Notifications
You must be signed in to change notification settings - Fork 20
Troubleshooting
Because an alize
definition tries to find the inverse relation via the inverse class immediately it can affect the load order of your models. This can cause problems in environments like dev where classes are being reloaded, or if your application requires specific model load order to boot up (rare, and not ideal).
The fix is pretty simply for this. Just break up your alize
into alize_to
and alize_from
. Place alize_from
on the side that you're storing the data. Put alize_to
on the side providing the data. And make sure to get them both the same fields (ideally from a const/helper, etc - keep it dry!)
See Issue 13.
If you are using Date
or DateTime
field types w/ alize you might run into this error. Alize stores denormalized attributes in hashes, and serialization by the moped driver breaks when it encounters a Date
or a DateTime
in a hash. Moped only adds the bson_dump method to the Time
class and not the Date
or DateTime
. The fix to your problem is simply to use a Time
type instead of the other types. In mongo, it's represented as a UTC time anyway so nothing should be different on the storage end. If you need to get Date/DateTime from the Time for some other reason you can do simple conversions in Ruby.