From 263764d13a9cd4eae60d1fa9e50af57f506f3dd4 Mon Sep 17 00:00:00 2001 From: Brian Morearty Date: Sun, 23 Sep 2012 08:19:02 -0700 Subject: Removed sorting of attribute names in controller generator. I believe when people use generators, they typically order the parameters on the command line in an order that makes sense to them. Sorting them in the generated code makes the order seem more arbitrary to humans, even though it's less arbitrary to computers. :-) Example: rails g scaffold Post title:string content:text The human chose to put title before content. Sorted attributes in the generated code work but don't match the human's intent: params.require(:posts).permit(:content, :title) --- .../rails/generators/rails/scaffold_controller/templates/controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb index 5d038d20e7..d6bce40b0c 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb @@ -94,7 +94,7 @@ class <%= controller_class_name %>Controller < ApplicationController <%- if attributes.empty? -%> params[<%= ":#{singular_table_name}" %>] <%- else -%> - params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes.map {|a| ":#{a.name}" }.sort.join(', ') %>) + params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes.map {|a| ":#{a.name}" }.join(', ') %>) <%- end -%> end end -- cgit v1.2.3