angular-rails-templates: Angular cannot find templates

I’m having a couple issues with Angular being able to find the templates I’ve created. I’m using angular-rails-templates with the ui router.

The templates will only load if I add “assets/” to the beginning of the templateUrl property. Without it, Angular returns a 404 not found. However, if I navigate in the browser to "localhost:3000/assets/sub- directory/file.html, the template will load.

Prepending “assets/” was an acceptable workaround in development, but the templates will not load at all in production. I have the app hosted on heroku.

The fact that the templateUrls require “assets/” in dev has me suspicious that angular-rails-templates is not working as designed in my app. I checked for any possible name collisions with my .js files and there are none.

For reference, I have injected templates in the module: .module("ootd", ['ngResource', 'templates', 'ui.router'])

I have required all the necessary js files in application.js:

//= require angular
//= require angular-resource
//= require angular-ui-router
//= require angular-rails-templates
//= require_tree ../templates
//= require_tree .

The templates live in “app/assets/templates/sub-directory/file.html”

I am using the “angular-rails” and “angular-rails-templates” gems in my gemfile.

Not sure if this is a bug or an issue with my code. Any help is appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

this gist may make some happy tough it invalidate pretty much everything that is good about this gem:

https://gist.github.com/pywebdesign/4be13c02c528e0bd7b91