There is a model post . Post are created by either PM or User. I want to get all posts in which the posts created by PM in last 24 hours come on top.
I try
posts.sort_by{|t| -t["role_id"] }
But by this PM all posts on top. I want PM posts of only last 24 hours on top.
Try this:
Post.where('created_at > ?', 24.hours.ago).order(role_id: :asc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With