I'm fetching a user using:
var user = this.store.find('user', user_id);
here is the user model:
export default DS.Model.extend({
username: DS.attr('string'),
email: DS.attr('string'),
first_name: DS.attr('string'),
last_name: DS.attr('string'),
password: DS.attr('string'),
is_admin: DS.attr('boolean')
});
im trying to run a before model where i check if the user is an admin and then do something if its true or false, example:
beforeModel: function(){
var user = this.store.find('user', 1);
if(user.get('is_admin')){
return 'do something since they are an admin';
}
},
I also tried doing this instead:
beforeModel: function(){
var user = this.store.find('user', 1);
return user.then(function(response){
if(response.is_admin){
return 'do something since they are an admin';
}
});
},
How can I get that is_admin
attribute in a route?
You could define
isAdmin
property in your route, and set it whenuser
promise resolved.