aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/middleware_stack_test.rb
diff options
context:
space:
mode:
authorRob Biedenharn <Rob@AgileConsultingLLC.com>2016-02-11 14:22:09 -0500
committerRob Biedenharn <Rob@AgileConsultingLLC.com>2016-07-08 17:12:14 -0400
commit3b49d792231f8051a82cee37c46ac5b23de844db (patch)
tree34cf9e4e67ca8a59ba78111fb5c6881c8993b579 /actionpack/test/dispatch/middleware_stack_test.rb
parentc62ac07be86a747f9b40ad25f60003e4f6022d26 (diff)
downloadrails-3b49d792231f8051a82cee37c46ac5b23de844db.tar.gz
rails-3b49d792231f8051a82cee37c46ac5b23de844db.tar.bz2
rails-3b49d792231f8051a82cee37c46ac5b23de844db.zip
fix to_param to maximize content
The documentation states that parameter values longer than 20 characters will be truncated by words, but the example shows that a parameter based on "David Heinemeier Hansson" (with id: 125) becomes "125-david" when "David Heinemeier".length == 16 so why so short? The answer lies in the use of the #truncate option omission: nil which seems to have been intended to mean "nothing", but which actually causes the default string "..." to be used. This causes #truncate to cleave words until the "..." can be added and still remain within the requested size of 20 characters. The better option is omission: '' (which is probably what was originally intended). Furthermore, since the use of #parameterize will remove non-alphanumeric characters, we can maximize the useful content of the output by calling parameterize first and then giving truncate a separator: /-/ rather than a space.
Diffstat (limited to 'actionpack/test/dispatch/middleware_stack_test.rb')
0 files changed, 0 insertions, 0 deletions