{"id":1267,"date":"2022-08-30T15:15:06","date_gmt":"2022-08-30T15:15:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/how-did-the-class-method-call-on-activerecordrelation-takes-a-context-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:06","modified_gmt":"2022-08-30T15:15:06","slug":"how-did-the-class-method-call-on-activerecordrelation-takes-a-context-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-did-the-class-method-call-on-activerecordrelation-takes-a-context-collection-of-common-programming-errors\/","title":{"rendered":"How did the class method call on ActiveRecord::Relation takes a context?-Collection of common programming errors"},"content":{"rendered":"<p>This works because returned object (AR::Relation) accepts 3 kind of methods:<\/p>\n<p>1) AR::Relation &#8216;native&#8217; methods like :where, :includes, :joins, :limit, etc&#8230;<\/p>\n<p>2) Enumerable methods. Most of them delegated to scoped collection, which is Array.<\/p>\n<p>3) Other methods: delegated to base class through &#8216;<strong>method_missing<\/strong>&#8216;<\/p>\n<p>So, API documentation in that part (chaining with class methods) is wrong \ud83d\ude42<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:13:08. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>This works because returned object (AR::Relation) accepts 3 kind of methods: 1) AR::Relation &#8216;native&#8217; methods like :where, :includes, :joins, :limit, etc&#8230; 2) Enumerable methods. Most of them delegated to scoped collection, which is Array. 3) Other methods: delegated to base class through &#8216;method_missing&#8216; So, API documentation in that part (chaining with class methods) is wrong [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1267","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1267"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1267\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}