在安装TracksApp时出现错误:ActionController :: RoutingError(没有路由匹配[GET]“/ tracks”)

时间:2015-09-26 11:14:22

标签: ruby-on-rails-4 rails-routing

我正在尝试在Nginx + Passenger上安装Tracks,并在尝试访问该网站时收到以下错误: The page you were looking for doesn't exist. 当我检查/log/production.log时,我看到以下记录:

ActionController::RoutingError (No route matches [GET] "/tracks"):
  actionpack (4.1.11) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.1.11) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.11) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.11) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.11) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.11) lib/active_support/tagged_logging.rb:26:in `tagged'

我怀疑我尝试在我的域中使用sub-uri的问题,即www.example.com/tracks,例如Redmine我需要在environment.rb添加以下行:

RedmineApp::Application.routes.default_scope = { :path => '/redmine', :shallow_path => '/redmine' }
...
Redmine::Utils::relative_url_root = "/redmine"

也许我需要在Tracks进行相同的更改,但我不知道rails。

这是来自负责此曲目的nginx.conf的配置:

location /tracks {
           passenger_enabled on;
           alias   /opt/tracks/public;
           index  index.html index.htm;
       }

提前谢谢。

1 个答案:

答案 0 :(得分:0)

好的,感谢我的朋友,他向我指出了这个教程:https://www.phusionpassenger.com/library/deploy/nginx/deploy/ruby/#deploying-an-app-to-a-sub-uri之后我在nginx.conf部分location /tracks中更改了以下内容:

location /tracks {
          passenger_base_uri /tracks;
          passenger_app_root /opt/tracks;
          passenger_document_root /opt/tracks/public;
          passenger_enabled on;
          alias   /opt/tracks/public;
          index  index.html index.htm;
      }

它解决了这个问题。