Reputation: 41
I'm building an app with AngularJS & Rails 4, and am using Heroku to host the site.
I placed several templates under an assets/templates folder as haml files.
I created a haml initializer with Rails.application.assets.register_engine '.haml', Tilt::HamlTemplate
and added the following line to my application.rb:
config.assets.paths << Rails.root.join('app', 'assets', 'templates')
I did this based on other threads on stackOverflow.
This works great locally, but when trying to access the site after pushing to heroku it can't seem to locate the templates in the assets/templates directory. I am referencing my template URL as templateUrl: ./assets/cityOverview.html
Specifically, my Heroku logs shows:
2014-02-10T05:17:25.042728+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/cityWelcome.html"):
What am I missing? should I move my templates to views?
Upvotes: 2
Views: 1077
Reputation: 3106
Your HTML templates on production may be appended with a hash! For instance, on development the file path will be /assets/cityOverview.html
but on production the Rails asset pipeline will add a hash like this: /assets/cityOverview-41ac8fc9a65390498a34680a9uc53951.html
This means you can't specify the template name in your JS file as "/assets/cityOverview.html"
. You can rename your js file to .js.erb and then write "<%=asset_path '/assets/cityOverview.html'%>"
. This ensures that the filename will have the hash as well.
Upvotes: 1
Reputation: 3655
Upvotes: 0