I bet this has a simple answer.. Let’s say I have a Post model and I want to have a scope that returns the ten most recent entries. I thought I could write the scope like this:
scope :first_ten order('created_at DESC').limit(10)
But this returns the error
syntax error, unexpected tIDENTIFIER, expecting keyword_end
scope :first_ten order('created_at ASC').limit(10)
How do I write this scope correctly? Thanks !
You are missing the comma which separates the two arguments being the name of the scope
:first_tenand the arel-objectorder('created_at ASC').limit(10)So i guess it should read
scope :first_ten, order('created_at DESC').limit(10)