Skip to content

Commit

Permalink
Simplify methods for generating order
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Hutchins & Stephen Barnes (candidate) authored and nertzy committed Nov 28, 2012
1 parent 6fa7be1 commit b3bffee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/pg_search/scope_options.rb
Expand Up @@ -11,7 +11,7 @@ def initialize(config)
end

def apply(scope)
scope.select("#{quoted_table_name}.*, (#{rank}) AS pg_search_rank").where(conditions).order("pg_search_rank DESC, #{order_within_rank}").joins(joins)
scope.select("#{quoted_table_name}.*, (#{rank}) AS pg_search_rank").where(conditions).order(order).joins(joins)
end

private
Expand All @@ -24,8 +24,8 @@ def conditions
end.join(" OR ")
end

def order_within_rank
config.order_within_rank || "#{primary_key} ASC"
def order
"pg_search_rank DESC, #{config.order_within_rank || "#{primary_key} ASC"}"
end

def primary_key
Expand Down

0 comments on commit b3bffee

Please sign in to comment.