What’s new in Rails 5.1: Better JavaScript, for one

Published March 1, 2017 by lagmen
What’s new in Rails 5.1: Better JavaScript, for one

Rails 5.1 allows developers to manage JavaScript dependencies with Facebook’s Yarn package manager

Ruby on Rails, the veteran server-side web framework, is playing nice with JavaScript in an upgrade that has recently moved to a first beta release.

Rails 5.1 offers multiple improvements, including encryption, system tests, and managing JavaScript dependencies from NPM via Facebook’s new Yarn package manager.

By managing JavaScript dependencies through Yarn, users can depend on libraries like React via NPM. Assets are made available in a pipeline, and the binstub bin/yarn is used to add these dependencies. Developers working with version 5.1 also can compile JavaScript using the Webpack module bundler, via a Webpacker gem. But Rails 5.1 drops jQuery as a default dependency. With the rewrite of rails-ujs unobtrusive scripting adapter to use vanilla JavaScript, this dependency is no longer needed.

Rails 5.1 also features an encrypted secrets management capability. An encrypted secrets file is set up by using the bin/rails secrets:setup capability, which generates a master key to store outside the repository while enabling developers to commit production secrets.

For system tests, Rails 5.1 includes a wrapping of the Capybara Ruby library for application testing. It comes preconfigured for the Chrome browser and enhanced with failure screenshots. The parameterized mailers feature offers the option to call mailers with parameters available before an action is invoked. Rails 5.1 simplifies form creation by unifying two hierarchies, form_for and form_tag, with form_with. A directed routes function, meanwhile, enables declaration of programmatic routes that can use Ruby to perform functions depending on parameters.

“We’ve had a stormy, perhaps even contentious, relationship with JavaScript over the years. But that time is past,” said a bulletin on the 5.1.0 release authored by dhh, who is presumably Rails founder David Heinemeier Hansson. JavaScript, the bulletin emphasizes, has “improved immensely” in recent years with the advent of ECMAScript 6 and tools like Yarn and Webpack.

Source: Infoworld.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: