Iron Router is breaking with meteor-pages

Hi there,

I’m trying to use the alethes:pages app with Iron Router and I’m running into some problems. My understanding is that Meteor.Paginator handles the route, which means that I’ve removed my normally specified Router.route(...) for /items/search/.

Another question, before you get to the code: once autopublish is removed, how are subscriptions handled if I’m no longer handling them in an Iron Router controller?

Here’s the code:

/app/lib/collections.js

Items = new Mongo.Collection('items');

this.Pages = new Meteor.Pagination(Items, {
  route: "/items/search/",
  router: "iron-router",
  routerTemplate: "ItemsSearch",
  routerLayout: "MasterLayout",
  sort: {
    name: 1
  },
  templateName: "ItemsSearch"
})`

/app/clients/items_search.html

<template name="ItemsSearch">
<p>We found these items matching your query.</p>
{{> pages}}
{{> pagesNav}}

{{#each items}}
  <div class="item-block" href="/items/{{slug}}">
    <img src="{{image}}"><br>
    <b>{{name}}</b> (r{{rarity}})
  </div>
{{/each}}
</template>

And here’s the crash log…

    Your app is crashing. Here's the latest log.


    /Users/ianmcqueen/.meteor/packages/meteor-tool/.1.1.4.1tli8fx++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
                throw(ex);
                      ^
    Error: A route for the path "/" already exists by the name of "home".
        at Iron.utils.assert (packages/iron:core/lib/iron_core.js:10:1)
        at Function.Router.route (packages/iron:router/lib/router.js:137:1)
        at app/lib/routes.js:11:8
        at app/lib/routes.js:39:3
        at /Users/ianmcqueen/Code/unitydb/app/.meteor/local/build/programs/server/boot.js:222:10
        at Array.forEach (native)
        at Function._.each._.forEach (/Users/ianmcqueen/.meteor/packages/meteor-tool/.1.1.4.1tli8fx++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
        at /Users/ianmcqueen/Code/unitydb/app/.meteor/local/build/programs/server/boot.js:117:5
    Exited with code: 8
    Your application is crashing. Waiting for file change.

Any thoughts? I’m not super familiar with this package and it doesn’t seem to be super actively maintained. Thanks in advanced.

You do it in your templates: http://guide.meteor.com/data-loading.html#organizing-subscriptions

I see. Thanks for that link. I’m new to Meteor, so I grasp the pub/sub concept pretty well, it’s just organizing it sometimes that I’m still learning.

Any reasons for the routing-based crash error from above though?

That’s why we have the guide!

But sorry, I don’t know much about the package you are using and don’t have time to look at it in depth at the moment.