Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit 12-2 #234

Open
redji opened this issue May 2, 2015 · 4 comments
Open

Commit 12-2 #234

redji opened this issue May 2, 2015 · 4 comments

Comments

@redji
Copy link

redji commented May 2, 2015

After moving posts subscription from router to route level '/posts/:_id' and '/posts/:_id/edit' routes stopped working for me. First one returned 404 and second one did not input the values to be edited. I fixed it by adding waitOn on each route for the post with the specified id. The problem is that in the live example of this commit everything works without this changes. What is odd Posts.find().fetch() for that page returns [], but the post is displayed despite that. How is it possible?

@SachaG
Copy link
Member

SachaG commented Sep 29, 2015

Did you get this to work eventually?

@tomthebuzz
Copy link

Same issue here... Always get server errors.
(webapp_server.js:419) Error serving static file Error: Forbidden

@jansigu
Copy link

jansigu commented Jun 13, 2016

I am experiencing the same problem. Followed the book. Seems like the _id property has gone. So you get a 404 when you try to submit, go to detail or edit. With the mongol add on you see that you get the list finds one post - but if you go to detail - the post collection is empty.

@JavicX
Copy link

JavicX commented Mar 21, 2017

Hello guys, the problem is that we can't reach the post data because we don't have the 'posts' subscription in Router.configure() anymore

I solve this adding a new publication to get just the post we need:

//...
Meteor.publish('post', function(postId) {
check(postId, String);
return Posts.find({ _id: postId });
});


publications.js

and changing the routes this way:


//...
Router.route('/posts/:_id', {
name: 'postPage',
waitOn: function () { return [Meteor.subscribe('comments', this.params._id), Meteor.subscribe('post', this.params._id)]; },
data: function () { return Posts.findOne(this.params._id); }
});

Router.route('/posts/:_id/edit', {
name: 'postEdit',
waitOn: function () { return [Meteor.subscribe('post', this.params._id)]; },
data: function () { return Posts.findOne(this.params._id); }
});

//...

router.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants