All threads / How to Upgrade to Turbolinks 5 Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to Upgrade to Turbolinks 5 Discussion

Hi Chris, great episode! You can also skip the extra gem(s) and compatibility files by simply changing code. Doing something like:

Old Turbolinks Classic:
$(document).on "ready page:load", ->
# CoffeeScript code

Turbolinks 5:
$(document).on "turbolinks:load", ->
# CoffeeScript code

https://github.com/turbolin...

Reply

Thanks for the great video Chris!

I keep getting an error though:

"couldn't find file 'compatibility' with type 'application/javascript'"

I think some things have changed since your video, like the compatibility file name, but other than that, I followed your video exactly.

The error is being raised in my application.html.erb. Also, I'm using turbolinks-source 5.0.0.beta2

Any thoughts?

Thanks,

Nick

The turbolinks/compatibility.coffee file doesn't ship with the gem unfortunately (at least not right now). You'll have to copy it into your Rails app from the original repo. I've got a link to it in the resources section above, but here's the link as well: https://github.com/turbolin... Paste that into your Rails app and just require the file like normal and you should be set.

Wow, thanks for the quick response!

I do have the compatibility file in my app/assets/javascripts directory and I'm requiring it my application.js file after the turbolinks require.

Do you think something has changed from beta1 one to beta2 that's causing the problem?

I don't believe so. It sounds like the normal error you get when trying to require a file that doesn't exist, although you have created it locally it sounds like. Possibly a typo in your filename?

Oh man! In an effort to avoid any spelling errors I copied and pasted the file name from the repo. The only problem is I copied an extra space at the end of the name so the file names didn't match up and I couldn't see it until I highlighted the file name! DOH!

Thanks for your help Chris! You're the man!

Ha, wow that's a subtle one. You'd think that it would automatically strip out spaces at the end of the filename by 2016. ;)

Reply

Hey chris, I'd like to build up product associations in the products edit view using modals. ie generating a specs table.

When i submit a form to the create action it re renders and closes the modal. adding data-turbolinks-permanent doesn't seem to solve the problem as the new specs won't show up

This form would be rather long for one page, is it possible to accomplish what I'm trying to do with turbolinks 5 or should I look to do something like breaking the form out into separate pages?

Cheers

It sounds like potentially what you want is the "remote: true" AJAX requests so that you can handle things on your own. Turbolinks won't really do anything here because the form is going to submit a POST and Turbolinks can only really handle GET requests. That's the main reason it's not going to be a good solution for your problem. I think using a JS response to the form submit should give you a lot more flexibility to do what you want there.

Reply

Thanks! You helped me a lot!

Reply

Hey Chris, I've been having trouble with turbo links. I'm not planning to upgrade my turbolinks and I have the jquery.turbolinks gem installed. The problem is that on first load my subscriptions_new submit button won't fire. It fires once I reload the page and everything works fine then. Any suggestions?

Reply
Laura326 ·

too bad the jquery.turbolinks gem doesn't work with Rails 5. any suggestions from implementing Turbolinks 5 with Rails 5 and Jquery?

Have you found a solution to this? I am having this issue currently.

Reply
Ron Huppert ·

Never mind. Comment removed.

Reply

Having issue with Rails 5 and Turbolinks. I have added the jquery-turbolinks gem and still having issues.

`application.js`

```

//= require jquery

//= require jquery.turbolinks

//= require jquery_ujs

//= require tether

//= require bootstrap-sprockets

//= require bootstrap-datepicker/core

//= require_tree .

//= require turbolinks
```

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.