diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index 43aa170..d450afa 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -9,7 +9,7 @@ module Searchkick :took, :error, :model_name, :entry_name, :total_count, :total_entries, :current_page, :per_page, :limit_value, :total_pages, :num_pages, :offset_value, :previous_page, :prev_page, :next_page, :first_page?, :last_page?, - :out_of_range?, :hits, :response, :to_a, :first, :highlights, :group_by, :misspellings?, :with_highlights, + :out_of_range?, :hits, :response, :to_a, :highlights, :group_by, :misspellings?, :with_highlights, :none?, :one?, :many? def_delegators :query, :params @@ -118,6 +118,10 @@ module Searchkick limit ? first(limit) : first end + def first(limit = nil) + limit ? self.limit(limit).to_a : self.limit(1).to_a.first + end + # TODO make more efficient if loaded def pluck(*fields) result = load(false) -- libgit2 0.21.0