Colin Law wrote in post #1182073: > On 9 March 2016 at 21:51, David Williams <li...@ruby-forum.com> wrote: >> "articles"."category_id" = ? ORDER BY "articles"."created_at" DESC >> [["category_id", 1]] >> >> >> I'm getting undefined method `each' for #<Article:0x8300868> > > That is because you only have a single Article, not a collection, see > above. > > Colin
Thanks for responding Colin, I didn't realize .last would lead to a single article being queried. I thought it would give me the last 10 records. I guess DESC being my default named_scope: default_scope -> { order(created_at: :desc) } should take care of that for me. Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b520e2182159037f5af7378e58f4745f%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.