Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-06-29 20:06:35 +0300
committerDouwe Maan <douwe@selenight.nl>2017-07-05 19:11:59 +0300
commitfe13f110412d85c05dc68e5ee1db499f681bf722 (patch)
tree4a2d172bb5a490ac8cadbcf376fbf815393ef22b /config/application.rb
parentdc7939337e0d72d2391c3bbb3082d644a54195af (diff)
Create and use project path helpers that only need a project, no namespace
Diffstat (limited to 'config/application.rb')
-rw-r--r--config/application.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/config/application.rb b/config/application.rb
index 3f39170a123..a9a961d7520 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -162,5 +162,25 @@ module Gitlab
config.generators do |g|
g.factory_girl false
end
+
+ config.after_initialize do
+ Rails.application.reload_routes!
+
+ project_url_helpers = Module.new do
+ Gitlab::Application.routes.named_routes.helper_names.each do |name|
+ next unless name.include?('namespace_project')
+
+ define_method(name.sub('namespace_project', 'project')) do |project, *args|
+ send(name, project&.namespace, project, *args)
+ end
+ end
+ end
+
+ Gitlab::Routing.url_helpers.include project_url_helpers
+ Gitlab::Routing.url_helpers.extend project_url_helpers
+
+ GitlabRoutingHelper.include project_url_helpers
+ GitlabRoutingHelper.extend project_url_helpers
+ end
end
end