Skip to content
Permalink
Browse files

Refactored postsLists route into a RouteController

chapter12-3
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent c298060 commit 223c5e991ff9a22a57a117aede3efd5305122a87
Showing with 19 additions and 11 deletions.
  1. +19 −11 lib/router.js
@@ -7,6 +7,24 @@ Router.configure({
}
});

PostsListController = RouteController.extend({
template: 'postsList',
increment: 5,
postsLimit: function() {
return parseInt(this.params.postsLimit) || this.increment;
},
findOptions: function() {
return {sort: {submitted: -1}, limit: this.postsLimit()};
},
waitOn: function() {
return Meteor.subscribe('posts', this.findOptions());
},
data: function() {
return {posts: Posts.find({}, this.findOptions())};

This comment has been minimized.

Copy link
@franmartin91

franmartin91 Jul 23, 2017

Here is the same error that i comment in Commit 12-2. Is "post:", not "posts:".

Regards.

}
});


Router.route('/posts/:_id', {
name: 'postPage',
waitOn: function() {
@@ -23,17 +41,7 @@ Router.route('/posts/:_id/edit', {
Router.route('/submit', {name: 'postSubmit'});

Router.route('/:postsLimit?', {
name: 'postsList',
waitOn: function() {
var limit = parseInt(this.params.postsLimit) || 5;
return Meteor.subscribe('posts', {sort: {submitted: -1}, limit: limit});
},
data: function() {
var limit = parseInt(this.params.postsLimit) || 5;
return {
posts: Posts.find({}, {sort: {submitted: -1}, limit: limit})
};
}
name: 'postsList'
});

var requireLogin = function() {

0 comments on commit 223c5e9

Please sign in to comment.
You can’t perform that action at this time.