peritor/simply_stored — Issue #17: uninitialized constant when using custom has_many association
Author: msolovyov
Created: 2011-10-21 20:23:10+00:00
State: open

Taking the example from the fixtures file in the simply_stored tests for User and Document.

When doing a_user.add_doc a_document, we get a 'NameError: uninitialized constant Doc'

Because in https://github.com/peritor/simply_stored/blob/master/lib/simply_stored/couch/has_many.rb#L61 we call simply_stored/class_methods_base.rb:5:in `get_class_from_name'" and then we are passing in 'docs' instead of the custom specified :class_name of Document.

So when defining the setter for has_many, it thinks that the class name is Doc instead of Document.

Here's a console output of this issue: https://gist.github.com/1304852