I’ve been following the tutorial at this site to create a jQuery CRUD form.
I have a model Artist which has a single validation, to check uniqueness of the display_name field.
When POST’ing the create action, the relevant parts of the WEBrick log is showing the following:
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)
I’m having difficulty understanding how when it’s obvious that in the parameters being passed through, display_name is set to a not null string, but in the validation query being run it is checking for an instance where it is null.
What is the source code for the “POST /artists” controller action?
That create action must access the
paramsappropriately. In this case, something like:Is your action calling
Artist.createwith the correctparams?