I am new in this world of Rails. And I cannot get my head around this problem. How to get @microposts ordered by the date the micropost was created.
This is the line
@microposts = current_user.followeds.map(&:microposts).flatten
I only managed to order by date the 'followeds', but that is not what I am looking for. All the attempts I have made gave me errors, so I guess I am not aware of some syntax.
Any help is welcome!
Normally, you would add an
orderclause, as in:The way you currently have this line structured doesn't permit that, however, since
orderis only available on ActiveRecord::Relations, and once you domapyou no longer have a Relation available to chain on.If that's the case, you'll want something like: