Serving Angular Templates from the Asset Pipeline
The way we’ve configured our routes, Angular will ask the server for the file /customer_search.html, which will result in a 404. We could place our view file in public, but most Rails deployments do not serve static assets from that directory, preferring to serve them from a CDN or a web server. Ideally, we want our templates managed the same as all other assets—through the asset pipeline.
That this is an HTML file poses a bit of a challenge, especially if we are using a CDN. Because our assets would be served from a different server on a different domain than our Rails application, most browsers won’t allow Angular to fetch the HTML file without configuring the CDN server for cross-origin ...
Get Rails, Angular, Postgres, and Bootstrap now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.