Proper way to conditionally render text in a template--or modified VALUE twice in a single render

I have a plugin that (almost) creates Digital Ocean Droplets and installs Discourse.

I have a page with a template that renders stuff about the Rails Model, the droplet that it creates, and the Discourse instance that gets installed on the droplet. I have all the information that need flowing between rails and ember with the MessageBus. I want to display different stuff depending on whether

  • there is enough info to create the droplet
  • task that creates the droplet is running (it updates stuff in the model)
  • Discourse has been installed

I keep getting

   You modified "hasStatus" twice on <@ember/component:ember660> in a single render.

EDIT: Well, that was because I had two computed functions watching the same thing…

I think I’ve finally realized that I can’t do this using something like {{#if hasStatus}} (which is a computed function) in the template since the page will need to be re-rendered to display the status after they click the “create droplet” button (as it’ll then set the installation_status variable which displays what is happening in the install.

Or maybe I have some other error that’s triggering that and what I’m doing should work?

So I guess what I need to do is use <gasp> CSS to hide the various elements?

1 Like

Well, as is often the case when I post things like this, the answer is even more bizarre than I could have imagined.

If I use stuff like {{#if server.value}} and have value pushed out by the MessageBus it works as expected if I do an update from the Rails console. I can set it to nil/not nil and the section of the page (dis)appears as expected. When I run my Ansible task from a terminal, Ansible pushes a new value via a route, which updates the record, which pushes it to the message bus and the section of the template appears as expected.

But, if Ansible gets run by a job by Discourse, I still see Rails claiming to push the stuff to the message bus. And I see in the browser javascript console that a computed function that tracks that value is firing and the value is null. If I reload the browser, the data is there and the page renders as expected. Maybe this is some vaguary of the dev environment and it’ll be different on production.

Maybe this is related?


Well, I’m still worried about that error, but I added


to my action and the page reloads and everything seems to work after that.

1 Like