I have a backbone app inside a Rails app working on local host that's not working on Heroku. It's giving me the usual "Sorry but something went wrong" message, although the rest of the Rails app works fine on Heroku. It's just this page specific backbone stuff. The error's getting thrown when it's trying to render the main view.
Started GET "/employeedirectory" for 207.230.251.130 at 2013-01-19 23:34:21 +0000
2013-01-19T23:34:21+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
The database is working and seeded on Heroku. Indeed, the error's getting thrown even before there's a query. I'm guessing it might be how the template system is set up. The index.html.erb page is essentially empty except for a few divs, into which the templates are inserted. The app uses this utility template loader (see code below) to load those templates. On local host, the templates referred to in get('templates/...)
are taken from the Rails public folder but the util.js file itself is located in the /assets/javascripts directory, which then gets copied to the public folder after precompile. I pushed it to Heroku with the same structure it uses on Heroku, although after the assets:precompile things might get changed around, and I'm not sure if that get('templates
can still retrieve those templates.
This is the public directory structure after assets:precompile
. the templates are sitting next to the assets folder.
Utils.js file that loads the templates
window.templateLoader = {
load: function(views, callback) {
var deferreds = [];
$.each(views, function(index, view) {
if (window[view]) {
deferreds.push($.get('templates/' + view + '.html', function(data) {
window[view].prototype.template = _.template(data);
}, 'html'));
} else {
alert(view + " not found");
}
});
$.when.apply(null, deferreds).done(callback);
}
};
The template loader loads the templates before the Backbone app is initialized like this
templateLoader.load(["HomeView", "ContactView", "HeaderView", "EmployeeView", "EmployeeSummaryView", "EmployeeListItemView"],
function () {
app = new Router();
Backbone.history.start();
});
so, to summarize, where in the Rails directory if not the public/templates folder, should i put the templates that are retrieved by the get function in this code so that they can be retrieved on Heroku
$.each(views, function(index, view) {
if (window[view]) {
deferreds.push($.get('templates/' + view + '.html', function(data) {
window[view].prototype.template = _.template(data);
}, 'html'));
} else {
alert(view + " not found");
}
});
If the templating isn't the problem, does anyone have any other ideas where I might look?