to straight point, have app profile accessible that:
this.resource('user', {path: '/user/:user_id'});
this can accessed visitors , (logged in users). have menu-bar has, logged in users, link user-profile (so /user/:loggedin-user_id). using ember-auth authenticate user , ember data models. problem here seems {{linkto 'user'}} doesn't work, because 1 user should link /user/28, next 1 /user/15. his/her own profile. kinda doesn't work, because how should ember know id display (though yes, don't understand underlying reasons fully). ember-auth provide app.auth.get('userid') id of logged in user, don't know how can tell ember know well.
so had know setting link manually via
<a {{bindattr href="app.loggedinuser"}}>
where-as variable gets set right url in application controller app.auth.get('userid'). works, quite hack.
is there 'ember' way of solving that?
ember-auth dev here.
straight solution:
first, ask ember-auth load user current user model. assuming user model called app.user
, , implements app.user.find(id)
.
app.auth = ember.auth.create # ... usermodel: 'app.user' # default null # pass string, not class app.user # access current user model # things ember, loaded asynchronously app.auth.get('user')
(copied docs.)
next, pass dynamic model handlebars links:
{{#linkto 'user' app.auth.user}}link current user{{/link}}
or otherwise - e.g. make binding app.auth.get('user')
, etc.
just in case, (js) app.get('foo')
equivalent ember-handlebars app.foo
.
Comments
Post a Comment