Commit 9d394250a8055f31d81e5538cb77f19ea6d0d79b
1 parent
f1c6bd8d
Exists in
master
and in
4 other branches
Add an inflector to mark "commits" as uncountable
Showing
1 changed file
with
21 additions
and
0 deletions
Show diff stats
config/initializers/inflections.rb
| ... | ... | @@ -8,3 +8,24 @@ |
| 8 | 8 | # inflect.irregular 'person', 'people' |
| 9 | 9 | # inflect.uncountable %w( fish sheep ) |
| 10 | 10 | # end |
| 11 | + | |
| 12 | +# Mark "commits" as uncountable. | |
| 13 | +# | |
| 14 | +# Without this change, the routes | |
| 15 | +# | |
| 16 | +# resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} | |
| 17 | +# resources :commits, only: [:show], constraints: {id: /.+/} | |
| 18 | +# | |
| 19 | +# would generate identical route helper methods (`project_commit_path`), resulting | |
| 20 | +# in one of them not getting a helper method at all. | |
| 21 | +# | |
| 22 | +# After this change, the helper methods are: | |
| 23 | +# | |
| 24 | +# project_commit_path(@project, @project.commit) | |
| 25 | +# # => "/gitlabhq/commit/bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a | |
| 26 | +# | |
| 27 | +# project_commits_path(@project, 'stable/README.md') | |
| 28 | +# # => "/gitlabhq/commits/stable/README.md" | |
| 29 | +ActiveSupport::Inflector.inflections do |inflect| | |
| 30 | + inflect.uncountable %w(commits) | |
| 31 | +end | ... | ... |