Note that there are some explanatory texts on larger screens.

plurals
  1. POWill_Paginate and order clause not working
    primarykey
    data
    text
    <p>I'm calling a pretty simple function, and can't seem to figure out whats going on. (I'm using rails 3.0.3 and the master branch of 'will_paginate' gem). I have the following code:</p> <pre><code> results = Article.search(params) # returns an array of articles @search_results = results.paginate :page =&gt; params[:page], :per_page=&gt;8, :order =&gt; order_clause </code></pre> <p>No matter what I make the order_clause (for example 'article_title desc' and 'article_title asc'), the results are always the same in the same order. So when I check using something like <code>@search_results[0]</code>, the element is always the same. In my view, they are obviously always the same as well. Am I totally missing something?</p> <p>I'm sure its something silly, but I've been banging my head against the wall all night. Any help would be much appreciated!</p> <p>Edited to Add: The search clause does the following:</p> <pre><code>def self.search(params) full_text_search(params[:query].to_s). category_search(params[:article_category].blank? ? '' : params[:article_category][:name]). payout_search(params[:payout_direction], params[:payout_value]). length_search(params[:length_direction], params[:length_value]). pending. distinct. all end </code></pre> <p>where each of these guys is a searchlogic based function like this:</p> <pre><code>#scopes scope :text_search, lambda {|query| { :joins =&gt; "INNER JOIN users ON users.id IN (articles.writer_id, articles.buyer_id)", :conditions =&gt; ["(articles.article_title LIKE :query) OR (articles.description LIKE :query) OR (users.first_name LIKE :query) OR (users.last_name LIKE :query)", { :query =&gt; "%#{query}%" }] } } scope :distinct, :select =&gt; "distinct articles.*" #methods def self.payout_search(dir, val) return no_op if val.blank? send("payment_amount_#{dir.gsub(/\s+/,'').underscore}", val) end def self.length_search(dir, val) return no_op if val.blank? send("min_words_#{dir.gsub(/\s+/,'').underscore}", val) end </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload