Currently my app is using the acts_as_votable gem and the default_scope is set to order posts by most up votes. All votes are cached, as seen in the acts_as_votable documentation. However after time my content will get stale, so I would like to have user posts sorted by most votes over the past 24 hours, similar to reddit.
class Post < ActiveRecord::Base
acts_as_votable
default_scope { order(:cached_votes_up => :desc) }
end
Additionally here is the schema.rb for the votes table, which has a created at field.
create_table "votes", force: :cascade do |t|
t.integer "votable_id"
t.string "votable_type"
t.integer "voter_id"
t.string "voter_type"
t.boolean "vote_flag"
t.string "vote_scope"
t.integer "vote_weight"
t.datetime "created_at"
t.datetime "updated_at"
end
Thanks in advance. Feel free to ask any questions.