If you recently added a Mongoid relationship that defines a specific “class_name” so that you can have a custom relationship name, and you’re getting an error like
“NoMethodError: undefined method `sub’ for :yourclassname:Symbol”
it might be coming from Mongoid::Relations::Metadata.class_name, which assumes that class_name is a string, not a symbol. Change the class_name on your relationship definition to a string, and it should be fixed.
Definitely saved my life! Will link to this article on my blog.
I’m glad it helped you. Hopefully nobody else will have to waste time trying to figure it out.
Thanks for posting this! very helpful!
You’re welcome, I’m glad it helped!