Search code examples
meteorcoffeescriptiron-router

Iron Router 1.0 subscription issue


Let me first say that I already put a post on on their issues board here.

Since upgrading to 1.0.0 all of my subscriptions aren't actually hitting my publications.

In my router, I have

# Projects home page
Router.route "/projects", (->
  waitOn: ->
    Meteor.subscribe("projects")
  action: ->
    @render
  @render "projectsHome"
),
  name: "projectsHome"

Then on my server I have

# Publish the Projects to the user
Meteor.publish 'projects', () ->
  console.log "Getting projects"
  Projects.find({})

I don't know if I am not doing this properly, but my server is never actually logging Getting projects

Now, after the page is loaded using this code, I run Meteor.subscribe("projects") in the browser console and all of my data shows up and the server logs the proper line.


Solution

  • Your CS syntax looks broken, try with this simpler example :

    Router.route '/projects',
      name: 'projectsHome'
      waitOn: ->
        Meteor.subscribe 'projects'
    

    Here is a variety of issues that could be the cause of your problem :

    • Wrapping the second argument of Router.route in parenthesis is pointless, and this argument should not be a function in the first place.
    • calling render in your overriding of action is useless : the default action is already rendering your template.
    • beware of your CS indentation, the line @render "projectsHome" looks very broken in this regard.