angular-rails-templates无法加载模板

jcu*_*nod 4 javascript ruby-on-rails angularjs angularjs-templates

我正在尝试让Angular加载模板:

var app = angular.module("myApp", ['templates'])
Run Code Online (Sandbox Code Playgroud)

和我的HTML:

<div ng-app="myApp">
  <div ng-include="'blah.html'"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

但我得到的只是404 Failed to load resource因为,Rails告诉我,No route matches [GET] "/blah.html".我知道这是因为Rails中的资产管道.blah.html是在/app/assets/javascripts/templates/blah.html,我正在使用angular-rails-templates宝石试图解决问题.所以我application.js有:

//= require angular-rails-templates
//= require_tree ./templates
Run Code Online (Sandbox Code Playgroud)

但我没有运气.

生成的html表明angular-rails-templates正在加载(它有一个脚本/assets/angular-rails-templates....js)但是rails无法找到blah.html

版本:
rails 4.2.1
angular-rails-templates 0.1.4
angularjs 1.3.15

jcu*_*nod 11

这原来是链轮不兼容(见这里这里)

简短版本是:

  1. 添加gem 'sprockets', '2.12.3'到您的Gemfile
  2. bundle update sprockets

[更新] 我不是这方面的专家,但似乎有些人比我建议使用更聪明/public/templates.你可能想要记住这一点.