Currently selected model conditional in a loop w/ link-to

I ended up down the rabbit hole on this but it was really bugging me and I couldn’t let it go. What I came up with is something like:

posts route:

actions: {
  setCurrentId: function(currentId) {
    console.log("currentId: " + currentId);
    this.controllerFor("posts").set("currentId", currentId);
  }
}

post route:

setupController: function(controller, model){
  this._super(controller, model);
  if (model) {
    this.controllerFor("posts").send("setCurrentId", model.id);
  }
}

However, you’ll still need to create a template helper as conditionals are limited. See this thread.

I don’t know if this is the best way to handle it but it’s the only thing that I’ve been able to make work.

EDIT: little change to add controllerFor() EDIT 2: see this truth helpers package