Hacker News new | ask | show | jobs
by arnvald 3676 days ago
Rails is a full-stack framework. One of its strengths is that out of the box you have everything there - database integration, http layer, also JavaScript.

Having said that - you have a choice. Rails is about defaults. By default it gives you jQuery, CoffeeScript and TurboLinks, but you don't have to use it at all. I've built a number of Rails apps and most of them use CoffeeScript, but don't use TurboLinks. It took me just a few seconds to remove it from my Gemfile.

Also, Rails API project is a subset of Rails that does not require JS (it was merged to Rails so you'll be able to generate API application in Rails 5).

1 comments

First thing I do when creating any Rails app is take out Turbolinks. It's like autopilot.
Turbolinks seem really great for the user. What do you not like about them?
One problem I've run into is that the Javascript state isn't reset when Turbolinks pretend-reloads the page. This can lead to "interesting" bugs if setInterval() calls or websocket-rails response handlers hang around when you navigate away from the page that they "expect" to be run on.

Attempting to reproduce these errors by refreshing the current page and repeating whatever you just did will not work, since the Javascript state will be wiped clean - you'll need to navigate through the same path that you took to get to that page in the first place. (This happened to me recently; as you may imagine, it took me a while to figure out what was going on!)

It's possible to work around this by "cleaning up" whenever a Turbolinks change event fires, of course, but the point is that you can't just add Turbolinks to your project and expect everything to work as it did before.