summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2012-09-25 18:45:13 -0400
committerRobert Speicher <rspeicher@gmail.com>2012-09-26 16:32:23 -0400
commit9d394250a8055f31d81e5538cb77f19ea6d0d79b (patch)
tree9a8adaafcc6e001f9f3bc195a5873056521de385
parentf1c6bd8df3225d33af4d3d032cc98be86317b348 (diff)
downloadgitlab-ce-9d394250a8055f31d81e5538cb77f19ea6d0d79b.tar.gz
Add an inflector to mark "commits" as uncountable
-rw-r--r--config/initializers/inflections.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb
index 9e8b0131f8f..5d46ece1e1b 100644
--- a/config/initializers/inflections.rb
+++ b/config/initializers/inflections.rb
@@ -8,3 +8,24 @@
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
+
+# Mark "commits" as uncountable.
+#
+# Without this change, the routes
+#
+# resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
+# resources :commits, only: [:show], constraints: {id: /.+/}
+#
+# would generate identical route helper methods (`project_commit_path`), resulting
+# in one of them not getting a helper method at all.
+#
+# After this change, the helper methods are:
+#
+# project_commit_path(@project, @project.commit)
+# # => "/gitlabhq/commit/bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a
+#
+# project_commits_path(@project, 'stable/README.md')
+# # => "/gitlabhq/commits/stable/README.md"
+ActiveSupport::Inflector.inflections do |inflect|
+ inflect.uncountable %w(commits)
+end