I'm a ruby and sphinx newb, and I'm having some trouble sorting using
integers.

I have a words table that keeps track of the total votes for a word.
However, I can't seem to sort it by votes. This is what I have so far:

# In words controller

def search
        @words = ThinkingSphinx::Search.search params[:search], :page =>
params[:page], :per_page => 1#, :order => :votes_count
  end

#In words model

        define_index do
                indexes word

#               set_property :delta => true

#               has id, created_at
        end

# In search model

      def search
        @words = Word.search params[:search]
      end

# In my search results

   <h1>Search words for your query</h1>
    <% for word in @words %>
      <% if word.class.name == "Word" %>
            <%= render :partial => "words/word", :locals => { :word =>
word } %>
      <% else %>
           <h1>There were no words for your query</h1><br/><br/>
      <% end %>
   <% end %>
<%= will_paginate @words %>

# and in my Database

create_table "words", :force => true do |t|
    t.string   "word"
    t.string   "language"
    t.text     "definition"
    t.string   "example"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "user_id",     :limit => 11
    t.integer  "votes_count", :limit => 11, :default => 0
  end


I'm trying to sort the search results by "votes_count" so that the
word with the most votes appears first (Descending).

Could some one help me out, I would really appreciate it.

Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to