Skip to content

Fix shorter route helpers in production environment

Sean McGivern requested to merge fix-routes-in-production-mode into master

I tested this locally by doing the following:

# master
[1] pry(main)> app.project_path(Project.first)
  Project Load (1.3ms)  SELECT  "projects".* FROM "projects"  ORDER BY "projects"."id" DESC LIMIT 1
NoMethodError: undefined method `project_path' for #<ActionDispatch::Integration::Session:0x007f9d1001ced0>
Did you mean?  projects_path
from /Users/seanmcgivern/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing'

# this branch
[1] pry(main)> app.project_path(Project.first)
  Project Load (1.3ms)  SELECT  "projects".* FROM "projects"  ORDER BY "projects"."id" DESC LIMIT 1
  Namespace Load (2.1ms)  SELECT  "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = $1  ORDER BY "namespaces"."id" DESC LIMIT 1  [["id", 1]]
  Route Load (0.4ms)  SELECT  "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT 1  [["source_id", 1], ["source_type", "Namespace"]]
=> "/root/mr-diff-commit-test-new"

I also applied this change to a VM with https://packages.gitlab.com/gitlab/nightly-builds/packages/ubuntu/xenial/gitlab-ce_8.1.0+git.3106.345e49a.54618-rc1.ce.0_amd64.deb installed, and restarted unicorn, and didn't get 500s everywhere any more 🙂

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/34741.

Merge request reports