从 rails 控制台工作,为什么以下find_by
返回 nil?
2.0.0 (main):0 > Location.last
Location Load (0.8ms) SELECT "locations".* FROM "locations" ORDER BY "locations"."id" DESC LIMIT 1
=> #<Location id: 92, district: nil, address: "8026 S KEDZIE AVE", city: "CHICAGO", state: "IL", zip: 60652, website: nil, location: nil, latitude: 41.7474748619454, longitude: -87.7023800625442, location_type: "fire_station">
2.0.0 (main):0 > lat = Location.last.latitude
Location Load (0.8ms) SELECT "locations".* FROM "locations" ORDER BY "locations"."id" DESC LIMIT 1
=> 41.7474748619454
2.0.0 (main):0 > Location.find_by( latitude: lat)
Location Load (0.8ms) SELECT "locations".* FROM "locations" WHERE "locations"."latitude" = 41.7474748619454 LIMIT 1
=> nil
我最初认为这与 Sqlite 有关,所以我切换到 Postgres 但仍然产生相同的结果。从事某个项目的其他人运行相同的操作find_by
产生了正确的结果。我的系统发生了什么情况?