{"id":170,"date":"2012-10-11T09:44:38","date_gmt":"2012-10-11T15:44:38","guid":{"rendered":"http:\/\/sha.nnoncarey.com\/blog\/?p=170"},"modified":"2012-11-16T18:14:09","modified_gmt":"2012-11-17T00:14:09","slug":"mongoid-nomethoderror-undefined-method-sub-for-sectionsymbol","status":"publish","type":"post","link":"https:\/\/sha.nnoncarey.com\/blog\/archives\/170","title":{"rendered":"Mongoid: NoMethodError: undefined method `sub&#8217; for :section:Symbol"},"content":{"rendered":"<p>If you recently added a Mongoid relationship that defines a specific &#8220;class_name&#8221; so that you can have a custom relationship name, and you&#8217;re getting an error like<\/p>\n<blockquote><p>&#8220;NoMethodError: undefined method `sub&#8217; for :yourclassname:Symbol&#8221;<\/p><\/blockquote>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you recently added a Mongoid relationship that defines a specific &#8220;class_name&#8221; so that you can have a custom relationship name, and you&#8217;re getting an error like &#8220;NoMethodError: undefined method `sub&#8217; for :yourclassname:Symbol&#8221; 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 &hellip; <a href=\"https:\/\/sha.nnoncarey.com\/blog\/archives\/170\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Mongoid: NoMethodError: undefined method `sub&#8217; for :section:Symbol&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-rails"],"_links":{"self":[{"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":3,"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":277,"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/posts\/170\/revisions\/277"}],"wp:attachment":[{"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sha.nnoncarey.com\/blog\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}