Skip to main content

Scheduling Posts Discussion

General • Asked by Chris Oliver
Related episode

Great tutorial - thanks! While everything appears to be working fine, I'm still running into the turbolinks caching issues you spoke of at the ~22min mark even after installing the jquery-turbolinks gem (and restarting the server). Is there some additional configuration that needs to happen in order for the gem to prevent that buggy js behavior? Thanks in advance!

That's a great question Brian. I think that what I was experiencing was that the jQuery code I wrote never gets re-executed when the page changes via Turbolinks. Usually jquery-turbolinks fixes that by hijacking the page change event and that automatically fixes it. You might double check to make sure that jquery-turbolinks is being included in your application.js file properly. That's about the only thing that I can think of off the top of my head.


I've gone through this, but when trying to load the form. I get `undefined method `published_at?' for nil:NilClass`.

My helper to my eye, looks word for word as per the example: (my model is article, not post)

module ArticlesHelper
def status_for(article)
if article.published_at?
if article.published_at > Time.zone.now
"Scheduled"
else
"Published"
end
else
"Draft"
end
end
end


To fix the Turbolinks issue you could put your js into a wrapper like this:

$(document).on("turbolinks:load", function() {
  # your javascript goes here...
});

What do you guys think?


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.