Rails 3.2 will not update the time used in a query -
i have following code:
@record = @user.records.where("question_group_id in (?)", @question_groups).ready.order(:next_ready).first
the method "ready" scope:
scope :ready, where("next_ready < :time", { time: time.now})
here's problem:
i need algorithm run quite often. selects question present user. select right question :time in scope must correct. it's not. system seems reusing same :time on , on again.
this not seem caching problem when empty cache , in case have setting in development:
config.action_controller.perform_caching = false
does know problem might be?
the value of time.now being set when source file first read, must change scope use lambda reevaluated every query
scope :ready, ->() { where("next_ready < :time", {:time => time.now}) }
Comments
Post a Comment