Displaying 2 results from an estimated 2 matches for "votes_count".
2006 Apr 03
2
Fast way of finding new position for model object?
...rs: number of votes ascending and age of
object descending. When a user adds or deletes a vote I need to
quickly update the associated model object''s position. Right now this
is done with the following method:
def update_position
position = nil
Bug.find(:all, :order => "votes_count DESC, id
ASC").each_with_index{ |bug,i|
if bug.id == self.id
position = i
break
end
}
self.insert_at(position)
end
Basically, find all of the bugs in the order in which they''re wanted
and then iterate through each until the new position of this...
2010 Jun 17
7
Why do rails calls a method when I'm calling a property?
...t exception:
undefined method `name'' for nil:NilClass
I don''t know why...here''s my controller:
#Controller starts here
class StoriesController < ApplicationController
before_filter :login_required, :only => [ :new, :create]
def index
get_stories ''votes_count >= 5''
end
def bin
get_stories ''''
render :action => ''index''
end
protected
def get_stories(conditions)
@stories = Story.find :all, :order => ''id DESC'', :conditions =>
conditions
end
def new
@st...