有人可以指出我以下的原因:
JobType.find 17
#=>
#<JobType id: 17, title: "some_title", description: "one description", reward: # <BigDecimal:1009bbb48,'0.1E1',9(18)>, min_payout: 0.019999999552965164, min_skill_score: 0.6000000238418579, max_payout: 1.0, max_skill_score: 0.9300000071525574, difficulty_level: 2.0, variable_reward: true>
JobType.where(id: 17).first
#=>
#<JobType id: 17, title: "some_title", description: "one description", reward: #<BigDecimal:1009bbb48,'0.1E1',9(18)>, min_payout: 0.02, min_skill_score: 0.6, max_payout: 1.0, max_skill_score: 0.93 difficulty_level: 2.0, variable_reward: true>
在数据库中,min_payout 的值是 0.6,max_skill_score 是 0.93,但是 find 返回那个奇怪的长浮点数。
记录的 SQL 查询:
# find
JobType Load (0.5ms) SELECT `job_types`.* FROM `job_types` WHERE `job_types`.`id` = ? LIMIT [["id", 17]]
# where
JobType Load (0.6ms) SELECT `job_types`.* FROM `job_types` WHERE `job_types`.`id` = 17
为什么 find 表现得那样。
我正在使用 rails 3.2.13 和 mysql gem。