我正在使用Easy Redmine PMS,我已经写过在rails中查询的地方,如:
Tracker.where(name: "+ Permits Required")
但它返回较少的值,而当我尝试检测查询以获取相同的数据时:
Tracker.all.detect{|i| i.name == "+ Permits Required"
它正在返回所有值。另外我注意到,当直接在数据库中获取数据时,我得到的值为Request Available
,而rails console返回Permits Required
。我已经尝试过postgresql和mysql这两个数据库的问题,问题是一样的。以下是查询:
2.1.1 :001 > @tra = Tracker.find_by_name("+ Camps & Finished Food Store")
Tracker Load (32.8ms) SELECT "trackers".* FROM "trackers" WHERE "trackers"."name" = $1 LIMIT 1 [["name", "+ Camps & Finished Food Store"]]
=> nil
2.1.1 :002 > @tra = Tracker.all.detect{|i| i.name == ("+ Camps & Finished Food Store")}
Tracker Load (0.9ms) SELECT "trackers".* FROM "trackers"
AnonymousUser Load (27.4ms) SELECT "users".* FROM "users" WHERE "users"."type" IN ('AnonymousUser') ORDER BY "users"."id" ASC LIMIT 1
EasyTranslation Load (28.6ms) SELECT "easy_translations".* FROM "easy_translations" WHERE "easy_translations"."entity_id" = $1 AND "easy_translations"."entity_type" = $2 AND "easy_translations"."entity_column" = $3 AND "easy_translations"."lang" = $4 ORDER BY "easy_translations"."id" ASC LIMIT 1 [["entity_id", 3], ["entity_type", "Tracker"], ["entity_column", "name"], ["lang", "en"]]
EasyTranslation Load (1.5ms) SELECT "easy_translations".* FROM "easy_translations" WHERE "easy_translations"."entity_id" = $1 AND "easy_translations"."entity_type" = $2 AND "easy_translations"."entity_column" = $3 AND "easy_translations"."lang" = $4 ORDER BY "easy_translations"."id" ASC LIMIT 1 [["entity_id", 4], ["entity_type", "Tracker"], ["entity_column", "name"], ["lang", "en"]]
EasyTranslation Load (0.7ms) SELECT "easy_translations".* FROM "easy_translations" WHERE "easy_translations"."entity_id" = $1 AND "easy_translations"."entity_type" = $2 AND "easy_translations"."entity_column" = $3 AND "easy_translations"."lang" = $4 ORDER BY "easy_translations"."id" ASC LIMIT 1 [["entity_id", 5], ["entity_type", "Tracker"], ["entity_column", "name"], ["lang", "en"]]
2.1.1 :003 > @tra = Tracker.where(name: "+ Camps & Finished Food Store")
Tracker Load (0.8ms) SELECT "trackers".* FROM "trackers" WHERE "trackers"."name" = $1 [["name", "+ Camps & Finished Food Store"]]
答案 0 :(得分:0)
Tracker.where(名称:“需要许可”)