RoR: Condition Always False - Why?

Posted by Matt Hollingsworth on Stack Overflow See other posts from Stack Overflow or by Matt Hollingsworth
Published on 2012-08-31T03:31:34Z Indexed on 2012/08/31 3:38 UTC
Read the original article Hit count: 137

Filed under:
|
|
|

Working in RoR 2.3.x. My quiz_results table has a row for user_id (3907) and result (0.1), and two users I'm looking at with no rows in the quiz_results table. This line keeps returining false:

-if QuizResult.find_by_user_id(@user_id).present?

But if I change it to anything that returns true, the next line reports an error on the * method:

="#{(QuizResult.average('score', :conditions => 'user_id = #{@user.id}') * 100).round}%"

The beginning of the code is a loop:

[email protected] do |user|

Any ideas how to fix? Have tried unsuccessfully all day.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about ruby-on-rails