Rails 4 nested resource hash not committed to database
This is my first app in Rails 4, but I'm not sure whether Rails 4 is the
problem.
I have nested resources as follows:
resources :made_games do
resources :made_game_instances
end
When I try to save a new made_game_instance this is what's happening in
the log:
Started POST "/made_games/11/made_game_instances" for 127.0.0.1 at
2013-09-10 12:03:55 -0700
Processing by MadeGameInstancesController#create as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"jEN2syjftjRtf3DBnijtp7gNVUEFrI+HYTUs+HFgo5M=",
"made_game_instance"=>{"new_word1"=>"bluesky"}, "commit"=>"Create Made
game instance", "made_game_id"=>"11"}
MadeGame Load (122.7ms) SELECT "made_games".* FROM "made_games" WHERE
"made_games"."id" = $1 LIMIT 1 [["id", "11"]]
(14.0ms) BEGIN
SQL (215.9ms) INSERT INTO "made_game_instances" ("created_at",
"made_game_id", "updated_at") VALUES ($1, $2, $3) RETURNING "id"
[["created_at", Tue, 10 Sep 2013 19:03:55 UTC +00:00], ["made_game_id",
11], ["updated_at", Tue, 10 Sep 2013 19:03:55 UTC +00:00]]
(5.7ms) COMMIT
Redirected to http://localhost:3000/made_games/11/made_game_instances/5
Completed 302 Found in 458ms (ActiveRecord: 358.3ms)
You can see that the params hash contains the hash where the
new_game_instance attribute :new_word1 is assigned the value "bluesky."
What I cannot figure out is why this assignment does not appear in the SQL
that is subsequently generated when the new 'made_game_instances' object
is created.
Additional information
Since this is Rails 4, in order to whitelist all the parameters (at least
at this stage in development), I have used permit! in the params private
method at the bottom of the controllers for both made_games and
made_game_instances.
No comments:
Post a Comment