I'm playing around with this demo app https://github.com/kagemusha/ember-rails-devise-demo that uses Ember to create a JavaScript implemenation of Devise registration for Rails. The app uses CoffeeScript. I converted it to JavaScript using the compiler on the coffeescript.org website, but now I'm getting these unexpected token and string errors.I'm very inexperienced with Ember and don't know how to make heads or tails of this error messages.
For example, at the top of the settings file, the code does this memoization check (syntax same for both the coffeescript and JavaScript version)
App.urls ||= {}
Which triggers this error when I load the app.
Uncaught SyntaxError: Unexpected token = :3000/assets/settings.js?body=1:1
Same thing happens with the same type of code in the authentications_helper file
App.Authentication ||= {}
Which triggers this error
Uncaught SyntaxError: Unexpected token = authentication_helper.js:1
However, it also obviously affects the rest of the code in the authentication_helper file. When I try to register, I click a link in a template
{{view App.MenuItem href="#/registration" label="Register"}}
which calls the register function in the App.RegistrationRoute
App.RegistrationRoute = Ember.Route.extend({
model: function() {
Ember.Object.create();
},
actions: {
register: function() {
log.info("Registering...");
App.Authentication.register(this);
},
which tries to trigger this register function in the authentication_helper file (the file with the App.Authentication ||= {}
at the top), but I'm getting an
Uncaught TypeError: Cannot call method 'register' of undefined
I'm guessing this App.Authentication isn't defined
because of the error relating to the unexpecting = in the caching function.
Have I given you enough code to help me make some progress on these errors?
App.Authentication.register = function(route) {
$.ajax({
url: App.urls.register,
type: "POST",
data: {
"user[name]": route.currentModel.name,
"user[email]": route.currentModel.email,
"user[password]": route.currentModel.password,
"user[password_confirmation]": route.currentModel.password_confirmation
},
success: function(data) {
App.currentUser = data.user;
App.LoginStateManager.transitionTo("authenticated");
route.transitionTo('home');
},
error: function(jqXHR, textStatus, errorThrown) {
route.controllerFor('registration').set("errorMsg", "That email/password combo didn't work. Please try again");
}
});
};