bloggr-client icon indicating copy to clipboard operation
bloggr-client copied to clipboard

Refresh on index.html#/posts/1 does not work

Open russellbits opened this issue 12 years ago • 3 comments

russellbits avatar Aug 16 '13 19:08 russellbits

Seems like you haven't created the PostController, happened to me as well. This looks for the post id in the url and loads the respective post

App.PostRoute = Ember.Route.extend({
    model: function(params) {
        return posts.findBy('id', params.post_id);
    }
});

skippednote avatar Sep 10 '13 02:09 skippednote

@skippednote I ran into the same issue and indeed hadn't created my ThingController. However, It still didn't work. After a little debugging I noticed Ember returns the ID as a string. Therefore, if (which was my case), your ID's are set as integers in your JSON, you'll need to tweak the code as follows :

App.PostRoute = Ember.Route.extend({
    model: function(params) {
        return posts.findBy('id', parseInt(params.post_id));
    }
});

benjaminhorner avatar Feb 26 '14 16:02 benjaminhorner

I also ran into the same problem as you guys. What I did to fix it was add the code

App.PostRoute = Ember.Route.extend({ model: function(params) { return posts.findBy('id', params.post_id); } });

I also needed to remove the {{format-date}} out of the index.html in the 'post' template and just leave 'date'. This is around the 13:40 mark of the video. I am not sure yet how it will affect it moving forward but to this point this seems to work.

Klanders85 avatar Jul 01 '14 16:07 Klanders85