Ask A Question


You’re not receiving notifications from this thread.

How do I implement a default_scope order when I'm using searchkick?

Jeramae Bohol asked in General

Before I implemented searchkick/elasticsearch on my rails app, the default_scope -> { order(created_at: :desc) } works. But after implementing searchkick/elasticsearch, it doesn't work anymore.


Since Searchkick is a whole separate process, it won't know about your Rails stuff. What I would say is if you write a helper method or class you can have it apply that scope to the options you pass in so that it always searches the same default scope.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 76,990+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.