我一直在关注这个站点上的教程来创建一个 jQuery CRUD 表单。
我有一个Artist
具有单一验证的模型来检查display_name
字段的唯一性。
当发布创建操作时,WEBrick 日志的相关部分显示如下:
Started POST "/artists" for 10.1.1.1 at 2012-10-07 13:50:00 +1300
Processing by ArtistsController#create as JS
Parameters: { (ommited parts for brevity) , "artist"=>{"display_name"=>"Banksy"}, "commit"=> "Create Artist"}
User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
Artist Load (0.5ms) SELECT `artists`.* FROM `artists`
(0.4ms) BEGIN
Artist Exists (1.4ms) SELECT 1 AS one FROM `artists` WHERE `artists`.`display_name` IS NULL LIMIT 1
(0.5ms) ROLLBACK
Rendered artists/create.js.erb (0.5ms)
Completed 200 OK in 71ms (Views: 55.5ms | ActiveRecord: 3.4ms)
我很难理解当很明显在传递的参数中display_name
设置为非空字符串时,但在运行的验证查询中,它正在检查它是否为空的实例。