diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-29 12:06:35 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-05 11:11:59 -0500 |
commit | fe13f110412d85c05dc68e5ee1db499f681bf722 (patch) | |
tree | 4a2d172bb5a490ac8cadbcf376fbf815393ef22b /config/application.rb | |
parent | dc7939337e0d72d2391c3bbb3082d644a54195af (diff) | |
download | gitlab-ce-fe13f110412d85c05dc68e5ee1db499f681bf722.tar.gz |
Create and use project path helpers that only need a project, no namespace
Diffstat (limited to 'config/application.rb')
-rw-r--r-- | config/application.rb | 20 |
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 |