From c83ace7b6a5720be30a2f7d843d545fc81af54cd Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Sun, 13 Dec 2015 19:37:22 +0100 Subject: Prevent a 500 in the default controller scaffold If you update a record with no attributes, you'll hit a 500 from a guard in `assign_attributes` raising: ```ruby ArgumentError: When assigning attributes, you must pass a hash as an argument. app/controllers/users_controller.rb:44:in `block in update' app/controllers/users_controller.rb:43:in `update' test/controllers/users_controller_test.rb:37:in `block in ' ``` Not a biggie, but may be quite confusing for the folks new to the framework. --- railties/test/generators/scaffold_controller_generator_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test/generators/scaffold_controller_generator_test.rb') diff --git a/railties/test/generators/scaffold_controller_generator_test.rb b/railties/test/generators/scaffold_controller_generator_test.rb index 95ef853a11..b4ba101017 100644 --- a/railties/test/generators/scaffold_controller_generator_test.rb +++ b/railties/test/generators/scaffold_controller_generator_test.rb @@ -56,7 +56,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase assert_file "app/controllers/users_controller.rb" do |content| assert_match(/def user_params/, content) - assert_match(/params\[:user\]/, content) + assert_match(/params\.fetch\(:user, \{\}\)/, content) end end -- cgit v1.2.3