Rails无法使用angular.js加载静态html模板

时间:2016-03-15 03:02:02

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

我得到了这个例外

  

没有路线匹配[GET]" /ng-template/manager/index.html"

在本地计算机上一切正常,但在部署到登台服务器后失败。

有什么想法吗?

角度路线

App.config(['$routeProvider', function($routeProvider) {
  $routeProvider.
  when('/',
    {
      templateUrl: '/ng-template/manager/index.html',
      controller: 'indexCtrl'}
  ).
  when('/api_usage',
    {
      templateUrl: '/ng-template/manager/api_usage.html',
      controller: 'ApiUsageCtrl'
    }

nginx.conf

    upstream myapp {
        server unix:/tmp/puma.myapp.sock fail_timeout=0;
    }

    server {
        listen      80;
        server_name www.myapp.com myapp.com;
        root /home/deploy/current/public ;

        location /assets/  {
            gzip_static on;
            expires max;
            add_header Cache-control public;
            add_header ETag "";
            break;
        }
        location ~* ^.+\.(jpg|jpeg|png|gif|ico|css|js)$ {
          expires max;
          try_files $uri @myapp;
        }
        location ~* ^.+\.(zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi|woff2|ttf|woff)$ {
            expires max;
            try_files $uri @myapp;
        }
        location @myapp {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass http://myapp;
            proxy_connect_timeout 10s;
            proxy_read_timeout 30s;
            proxy_buffers 8 16k;
            proxy_buffer_size 32k;
        }
        try_files $uri/index.html $uri @myapp;
        error_page 500 502 503 504 /500.html;
        client_max_body_size 4G;
        keepalive_timeout 10;
    }

production.rb

Rails.application.configure do
  config.eager_load = true
  config.serve_static_files = true
  config.assets.js_compressor = :uglifier
  config.assets.css_compressor = :sass
  config.assets.compile = true
  config.assets.digest = true
end

0 个答案:

没有答案