For each one of us who’s been waiting for the release of the all-new and neat and clean version of Rails 5.1, the wait is over. The new version of Rails 5.1 easily accepts the SPA (Single Page Application) and it also represents a genuine upgradation in terms of performance and structure of Rails, one of the most popular frameworks. A multitude of improvements such as system testing, encryption and managing JavaScript dependencies are supported by Rails 5.1
Some Rails 5.1 features are listed below:
Ruby Version
It requires Ruby 2.3.1 or greater version of ruby.No More RAKE Commands
When we want to run a migration in Rails 4 we need to type rake db:migrare, but in Rails 5.1 this will become rotaie db:migrare. In Rails 5.1 all the current rake commands will be accessible via the rails command.We can now restart all of our apps with the command rake restart.App Server
In Rails 5.1 app, by default Puma server is present in Gemfile.Yarn Support
Yarn is like a Bundler for managing JavaScript dependencies from NPM.with this we can easily use libraries like React, VueJS or any other library from NPM world. It is integrated with the asset pipeline so that all dependencies will work seamlessly with the Rails 5.1 app. On Debian or Ubuntu Linux, to install Yarn via Debian package repository follow the below command:Webpacker Support
Webpack can used to compile Javascript using webpacker gemma. It is used to manage modules and dependencies.If we are in the single page applications,easily we can setup React, Angular, E Vue.js. To start a Rails/React project we can run the below command: For an existing project, first we need to add the webpacker gem in Gemfile,then run the above command. In the same way we create the app for Angular and Vue.js.For more information on webpacker refer this link https://github.com/rails/webpacker.New form_with helper
A new form_with helper has been added in Rails 5.1 which combines form_for and form_tag methods.Direct and Resolved Routes
These two new methods direct and resolved has been added to the Routing DSL. The diretto method allows creation of custom URL helpers. Example: The resolve method allows us to customize polymorphic mapping of models. This will generate the singular URL /product instead of the usual /products/:id.Parameterized Mailers
Now in mailers we can define before action by passing in parameters to the method. This parameters will be used for all methods in a mailer class, in order to share instance variables, headers and other common setup. Example:New Tag helper
The ActionView tag helper has been changed to provide a cleaner and readable syntax:System tests
The best solution for system tests on Ruby was using Capybara. Using it currently involves setting up Capybara in our project, along with a strategy for cleaning our database with tools like database_cleaner and launchy gem to help us to debug when an error happens. Looking to get your app developed? RailsCarma può aiutare! Dai un'occhiata al nostro portafoglio per capire come stiamo contribuendo a cambiare la forma dell'industria del software fornendo Sviluppatore di Ruby on Rails. Mettiti in contatto con noi adesso! Salva SalvaIscriviti per gli ultimi aggiornamenti
Articoli correlati