Ember-Data is definitely helpful, but I found myself in need of a custom solution to retrieve a user based on the invitation_token
and also trigger a different controller action on the backend Rails system.
Check out the route I came up with:
MyEmberApp.InviteRoute = Ember.Route.extend({
model: function(params) {
var self = this;
var user;
$.ajax({
type: 'GET',
url: 'api/v1/users/invite?invitation_token=' + params.token,
success: function(response) {
user = self.store.createRecord('user', response.users[0]);
console.log(user);
return user;
},
error: function(response) {
console.log("Oops, something went wrong.");
}
});
},
setupController: function(controller, model) {
controller.set('model', model);
console.log(model);
},
});
In the setupController
section, the console.log(model)
shows as undefined - could it be related to using an $.ajax
call? Any ideas on how to proceed? Using pure ember-data isn't feasible for me since I require user authorization at the Rails controller level.