{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/52778818","id":52778818,"diff_hunk":"@@ -29,10 +30,23 @@ def test_to_param_class_method\n     assert_equal '4-flamboyant-software', firm.to_param\n   end\n \n+  def test_to_param_class_method_truncates_words_properly\n+    firm = Firm.find(4)\n+    firm.name << ', Inc.'\n+    assert_equal '4-flamboyant-software', firm.to_param\n+  end\n+\n+  def test_to_param_class_method_truncates_after_parameterize\n+    firm = Firm.find(4)\n+    firm.name = \"Huey, Dewey, & Louie LLC\"","path":"activerecord/test/cases/integration_test.rb","position":17,"original_position":17,"commit_id":"a05a08d795af50e80176c66e163ceaabe0a47be3","original_commit_id":"a05a08d795af50e80176c66e163ceaabe0a47be3","user":{"login":"rab","id":21304,"avatar_url":"https://avatars.githubusercontent.com/u/21304?v=3","gravatar_id":"","url":"https://api.github.com/users/rab","html_url":"https://github.com/rab","followers_url":"https://api.github.com/users/rab/followers","following_url":"https://api.github.com/users/rab/following{/other_user}","gists_url":"https://api.github.com/users/rab/gists{/gist_id}","starred_url":"https://api.github.com/users/rab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rab/subscriptions","organizations_url":"https://api.github.com/users/rab/orgs","repos_url":"https://api.github.com/users/rab/repos","events_url":"https://api.github.com/users/rab/events{/privacy}","received_events_url":"https://api.github.com/users/rab/received_events","type":"User","site_admin":false},"body":"I don't understand your concern. The benefit to parameterizing prior to truncation is that characters that will no make it into the final result do not influence the truncation. In this case, the commas and the ampersand will not be used in the result, but that makes the length 4 characters more for no reason. In this way we are truncating the URL parameter rather than parameterizing the truncated attribute.","created_at":"2016-02-12T18:30:44Z","updated_at":"2016-02-12T18:30:44Z","html_url":"https://github.com/rails/rails/pull/23636#discussion_r52778818","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/23636","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/52778818"},"html":{"href":"https://github.com/rails/rails/pull/23636#discussion_r52778818"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/23636"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/23636","id":59188145,"html_url":"https://github.com/rails/rails/pull/23636","diff_url":"https://github.com/rails/rails/pull/23636.diff","patch_url":"https://github.com/rails/rails/pull/23636.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/23636","number":23636,"state":"open","locked":false,"title":"fix to_param to maximize content","user":{"login":"rab","id":21304,"avatar_url":"https://avatars.githubusercontent.com/u/21304?v=3","gravatar_id":"","url":"https://api.github.com/users/rab","html_url":"https://github.com/rab","followers_url":"https://api.github.com/users/rab/followers","following_url":"https://api.github.com/users/rab/following{/other_user}","gists_url":"https://api.github.com/users/rab/gists{/gist_id}","starred_url":"https://api.github.com/users/rab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rab/subscriptions","organizations_url":"https://api.github.com/users/rab/orgs","repos_url":"https://api.github.com/users/rab/repos","events_url":"https://api.github.com/users/rab/events{/privacy}","received_events_url":"https://api.github.com/users/rab/received_events","type":"User","site_admin":false},"body":"To fix #23635\r\n\r\nThe documentation states that parameter values longer than 20 characters\r\nwill be truncated by words, but the example shows that a parameter based\r\non \"David Heinemeier Hansson\" (with id: 125) becomes \"125-david\" when\r\n\"David Heinemeier\".length == 16 so why so short?\r\n\r\nThe answer lies in the use of the #truncate option omission: nil which\r\nseems to have been intended to mean \"nothing\", but which actually causes\r\nthe default string \"...\" to be used. This causes #truncate to cleave\r\nwords until the \"...\" can be added and still remain within the requested\r\nsize of 20 characters.\r\n\r\nThe better option is omission: '' (which is probably what was originally\r\nintended).\r\n\r\nFurthermore, since the use of #parameterize will remove non-alphanumeric\r\ncharacters, we can maximize the useful content of the output by calling\r\nparameterize first and then giving truncate a separator: /-/ rather than\r\na space.","created_at":"2016-02-12T15:33:32Z","updated_at":"2016-02-12T18:30:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5a6da05a64723a6a436cea5b334f2ccb06173365","assignee":{"login":"arthurnn","id":833383,"avatar_url":"https://avatars.githubusercontent.com/u/833383?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurnn","html_url":"https://github.com/arthurnn","followers_url":"https://api.github.com/users/arthurnn/followers","following_url":"https://api.github.com/users/arthurnn/following{/other_user}","gists_url":"https://api.github.com/users/arthurnn/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurnn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurnn/subscriptions","organizations_url":"https://api.github.com/users/arthurnn/orgs","repos_url":"https://api.github.com/users/arthurnn/repos","events_url":"https://api.github.com/users/arthurnn/events{/privacy}","received_events_url":"https://api.github.com/users/arthurnn/received_events","type":"User","site_admin":true},"milestone":null,"commits_url":"https://api.github.com/repos/rails/rails/pulls/23636/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/23636/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/23636/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/a05a08d795af50e80176c66e163ceaabe0a47be3","head":{"label":"rab:fix-to_param-truncation","ref":"fix-to_param-truncation","sha":"a05a08d795af50e80176c66e163ceaabe0a47be3","user":{"login":"rab","id":21304,"avatar_url":"https://avatars.githubusercontent.com/u/21304?v=3","gravatar_id":"","url":"https://api.github.com/users/rab","html_url":"https://github.com/rab","followers_url":"https://api.github.com/users/rab/followers","following_url":"https://api.github.com/users/rab/following{/other_user}","gists_url":"https://api.github.com/users/rab/gists{/gist_id}","starred_url":"https://api.github.com/users/rab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rab/subscriptions","organizations_url":"https://api.github.com/users/rab/orgs","repos_url":"https://api.github.com/users/rab/repos","events_url":"https://api.github.com/users/rab/events{/privacy}","received_events_url":"https://api.github.com/users/rab/received_events","type":"User","site_admin":false},"repo":{"id":51530344,"name":"rails","full_name":"rab/rails","owner":{"login":"rab","id":21304,"avatar_url":"https://avatars.githubusercontent.com/u/21304?v=3","gravatar_id":"","url":"https://api.github.com/users/rab","html_url":"https://github.com/rab","followers_url":"https://api.github.com/users/rab/followers","following_url":"https://api.github.com/users/rab/following{/other_user}","gists_url":"https://api.github.com/users/rab/gists{/gist_id}","starred_url":"https://api.github.com/users/rab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rab/subscriptions","organizations_url":"https://api.github.com/users/rab/orgs","repos_url":"https://api.github.com/users/rab/repos","events_url":"https://api.github.com/users/rab/events{/privacy}","received_events_url":"https://api.github.com/users/rab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rab/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/rab/rails","forks_url":"https://api.github.com/repos/rab/rails/forks","keys_url":"https://api.github.com/repos/rab/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rab/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rab/rails/teams","hooks_url":"https://api.github.com/repos/rab/rails/hooks","issue_events_url":"https://api.github.com/repos/rab/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rab/rails/events","assignees_url":"https://api.github.com/repos/rab/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rab/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rab/rails/tags","blobs_url":"https://api.github.com/repos/rab/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rab/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rab/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rab/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rab/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rab/rails/languages","stargazers_url":"https://api.github.com/repos/rab/rails/stargazers","contributors_url":"https://api.github.com/repos/rab/rails/contributors","subscribers_url":"https://api.github.com/repos/rab/rails/subscribers","subscription_url":"https://api.github.com/repos/rab/rails/subscription","commits_url":"https://api.github.com/repos/rab/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rab/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rab/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rab/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rab/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rab/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rab/rails/merges","archive_url":"https://api.github.com/repos/rab/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rab/rails/downloads","issues_url":"https://api.github.com/repos/rab/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rab/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rab/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rab/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rab/rails/labels{/name}","releases_url":"https://api.github.com/repos/rab/rails/releases{/id}","deployments_url":"https://api.github.com/repos/rab/rails/deployments","created_at":"2016-02-11T17:02:08Z","updated_at":"2016-02-11T17:03:09Z","pushed_at":"2016-02-12T15:42:07Z","git_url":"git://github.com/rab/rails.git","ssh_url":"git@github.com:rab/rails.git","clone_url":"https://github.com/rab/rails.git","svn_url":"https://github.com/rab/rails","homepage":"http://rubyonrails.org","size":126785,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"f7aa4c92a0a0dd609b6e07a5db256c417d0aa235","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","deployments_url":"https://api.github.com/repos/rails/rails/deployments","created_at":"2008-04-11T02:19:47Z","updated_at":"2016-02-12T16:45:27Z","pushed_at":"2016-02-12T18:30:06Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":326152,"stargazers_count":29655,"watchers_count":29655,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12033,"mirror_url":null,"open_issues_count":881,"forks":12033,"open_issues":881,"watchers":29655,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/23636"},"html":{"href":"https://github.com/rails/rails/pull/23636"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/23636"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/23636/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/23636/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/23636/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/a05a08d795af50e80176c66e163ceaabe0a47be3"}}}}