Ruby on Rails has completely changed the world of web development since its first version in 2004. From the very beginning it has become a powerful framework that allows web applications to be built with relative ease. It’s a framework designed with developer productivity and happiness in mind. It’s also a framework that continues to change and evolve!

So, Rails 5.0.0.beta1.1 is here! The first beta version has been released with the new features and major changes. So, let’s take a quick tour and find out what’s new in Rails 5.0.0.beta1.

Action Cable

Nowadays, push notifications are a big deal for marketing. Until Rails5, RoR developers had to look for an alternate solution. Luckily, now with the new release, we will have an out of box solution Action Cable, which in fact is a client on the server to manage all the notifications correctly.

Application Record

In the earlier version of RoR, all models were inherited from ActiveRecord::Base. However, now all the models will be inherited from ApplicationRecord. It’s a class, which will be used for customization and extensions for an application. It will be used instead of monkey patching ActiveRecord::Base.

On the other hand, if you want to add an extra functionality to ApplicationRecord then it will be localized to the models inheriting from ApplicationRecord.

Rails API

The rails-api gem has been merged into Rails. It allows you to generate API-only applications. You can now generate an API-only app using the –api option:

rails new my-app-api --api

ActiveRecord::Relation#or

We finally have the #or method in ActiveRecord. You can use it like:

classIssue < ApplicationRecord
scope:reported,->{where(status:'reported')}
scope:open,->{where(status:'open')}
end

ActiveRecord::Relation#in_batches

Person.where('age >= 18').in_batches(of:1000)do|people|
people.update_all(can_vote:true)
end

ActiveRecord::Base#has_secure_token

So, you want a random token in your model, I would suggest you to use this secure token.3

For an example

classUser < ApplicationRecord
has_secure_token:email_unsubscribe_token
end
user=User.create
user.email_unsubscribe_token#=> 'e2426a93718d1817a43abbaa'
user.regenerate_email_unsubscribe_token

AttributesAPI

Now onwards, your models will get a new attribute class method in Rails 5 that allows you to easily define a relationship between the model and a non-Active Record type.

Supports only Ruby 2.2.2+

As per the new maintenance policy, the release of Rails 5.0 will only apply to 5.0.0. & 4.2.0. Its severe security issues will also support to 5.0.x and 4.2.0. It means 4.1.0 and below will essentially be unsupported! Ruby 2.2.2+ is now also the only supported version of Ruby for Rails & above it tends to be faster and even better.







About the Author

Storyteller, Marketer, Developer, Writer, Thinker, Enabler, Rescuer, Wordsmith. I see myself as a Content Strategist. I love to write about anything and everything that pertains to the digital world, as I believe it’s an ever evolving space creative in its own way. I love facing challenges, Blogging and sharing technologies