无法加载assets / templates / name.html中的资源

时间:2014-04-07 16:37:34

标签: ruby-on-rails angularjs heroku

我有一个由Rails应用程序支持的Angular应用程序的工作副本。

我将Angular模板放在app / assets / templates / devices /中,当我需要使用模板时,我这样做:

when("/devices", {templateUrl: "assets/devices/select.html", controller: "DevicesListCtrl"})

这在我的本地机器上工作正常,但在上传到Heroku时,我收到以下错误:

Failed to load resource: the server responded with a status of 404 (Not Found) 

有关我应该如何处理的任何想法?

我也尝试过使用以下内容:

//= depend_on_asset devices/index.html
//= depend_on_asset devices/show.html
//= depend_on_asset devices/select.html

window.App = angular.module('TestApp', ['ngResource', 'ngRoute']);

App.config(['$routeProvider', function($routeProvider) {
  $routeProvider.
    when("/devices", {templateUrl: "<%= asset_path('assets/devices/index.html') %>", controller: "DevicesListCtrl"}).
    when("/devices/:id", {templateUrl: "<%= asset_path('assets/devices/show.html') %>", controller: "DevicesShowCtrl"}).
    when("/", {templateUrl: "<%= asset_path('assets/devices/select.html') %>", controller: "DevicesSelectCtrl"}).
    otherwise({redirectTo: '/devices'});
}]);

但我仍然得到404 ......

1 个答案:

答案 0 :(得分:1)

我认为您不应在网址中添加“资产”。

这样做:

asset_path('devices/index.html');