admin管理员组

文章数量:1122832

In production the nested route works but in development the route doesn't work. I get either undefined constant error from CanCan or it routes to a diferent parent route with a similar name.

I didn't develop this initially so not sure on the history of how it was built. It is also on version 3 of RoR, so finding answers for this is not so easy.

There are several other routes using this nested route and there is only one with this issue.

The controllers are setup as so

class Reports::ProjectsController < ApplicationController

  load_resource

  before_filter :set_active_tab

  ----code


end

Rake routes show the routing as expected but when trying to load the page it routes to another parent route - it is similarly named.

reports_projects GET    /reports/projects(.:format)                                                     reports/projects#index

but when I try to load the page the routing log shows which is not the expected

Started GET "/reports/projects" for 127.0.0.1 at 2024-12-27 13:22:00 +0100
Processing by ProjectsController#index as HTML

If I go to Production or Staging the routing works as expected

Started GET "/reports/projects" for 127.0.0.1 at 2025-01-06 12:32:32 +0100
Processing by Reports::ProjectsController#index as HTML

How can this be resolved?

本文标签: Ruby on Rails Nestled Route going to wrong routeStack Overflow