1

我正在使用 Angular 和 Rails 编写应用程序。我有后备ApplicationController

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :intercept_html_requests

  private

  def intercept_html_requests
    render('pages/index') if request.format == Mime::HTML
  end
end

和路由器一样:

betly.config(function($routeProvider, $locationProvider) {
  $locationProvider.html5Mode(true);

  $routeProvider.when('/', {
    templateUrl: 'assets/tournaments.html',
    controller: 'tournamentController'
  }).when('/aaa', {
    templateUrl: 'assets/tournaments.html',
    controller: 'tournamentController'
  }).when('/matches/:matchId',{
    templateUrl: 'assets/matchDetails.html',
    controller: 'matchController'
  }).otherwise({
    redirectTo:'/'
  });
});

views/layouts/application.html.erb

<!DOCTYPE html>
<html lang="en" ng-app>
  <head>
    <meta charset='utf-8' />
    <title>BetLy</title>
    <%= stylesheet_link_tag    "application", media: "all" %>
    <%= csrf_meta_tags %>
  </head>
  <body>
    <%= yield %>
    <%= javascript_include_tag "application" %>
  </body>
</html>

当我试图去/matches/10浏览器无限下载资产时。为什么以及如何解决这个问题?

4

1 回答 1

0

问题出在路线文件中。当您尝试捕获 Rails 应用程序中的所有路线时,您不应该添加/路线,因此它应该如下所示:

match '*any', to: 'controller#method'

代替

match '/*any', to: 'controller#method'
于 2013-06-05T12:54:59.170 回答