Developer should know this 5 developing tips for Ruby on Rail

Developing Tips For Ruby Rail


I didn’t meet this in anybody’s code for a long time of RoR development and found as of late. What’s more, it’s conspicuous why :- ) The main Ruby form I worked with was 1.8, however this technique was presented in 2.3.

How frequently did you accomplish something like this:

… if params[:user] && params[:user][:address] && params[:user][:address][:somewhere_deep]

Consider dig sort of safe navigation operator and. in any case, for Hash objects. So now you could revamp such things:

… if params.dig(:user, :address, :somewhere_deep)


This one I found in the great article about Query Objects in Ruby on Rails. It enables you to supplant conditionals (frequently ternary) with single technique call when you don’t really require a boolean consequence of incorporation check, yet a checked protest itself. For instance, your code resembles:

sort_options = [:by_date, :by_title, :by_author]

sort = sort_options.include?(params[:sort])
? params[:sort]
: :by_date
# Another option
sort = (sort_options.include?(params[:sort]) && params[:sort]) || :by_date

Does this look better?

ruby on rails

params[:sort].presence_in(sort_options) || :by_date


All things considered, I discovered this extremely helpful when I took a shot at a venture with a heritage database. It had a table with odd section names like SERNUM_0, ITMDES1_0 and other. We mapped this table to an ActiveRecord show and as opposed to writing queries and extensions on it like WeirdTable.where(SERNUM_0: ‘123’) , we came up to utilizing alias_attribute since it doesn’t simply create getter and setter (and also a predicate strategy), yet works in queries too:

alias_attribute :name, :ITMDES1_0

scope :by_name, -> (name) { where(name: name) }


This one is more well known than others. There’s truly great clarification on ApiDock. Along these lines, object.presence is equal to:

object.present? ? object : nil

If you want to learn Ruby on Rails from scratch then watch this video below:

Image Source: Freepik

Design Better Mobile Apps Using This Tips

Mobile app design tips

To make your work simple, here are some valuable tips to enable you to design a magnificent UI that will add on to the visual interest of your mobile application :-

1. Right-Size Graphics

mobile app design tips

With regards to graphics, developers for the most part take after the thumb manage of ‘one size fits most’, which is really a wrong approach. Almost certainly, this makes resource management more straightforward yet it can hurt the visual interest of your application.

For your application to look awesome, incorporate graphics that are custom fitted to the screens of the particular gadgets. The best graphics in a perfect world load at run time and sum to a charming client encounter by and large.

2. About Users

tips for mobile app design

Affirm, that is an easy decision, yet at the same time, you should know your users all around. That records for all the demographic data that your examination application can follow. In any case, more than that, you should comprehend what all they require and what are the issues they look in accomplishing their objectives.

It requires a lot of sympathy for the users and for that you have to go past the essential details. You should know the general population who are the users of your mobile application.

For this, you can address them eye to eye or watch them utilizing your item or even ask them their sentiment on design and so forth. It isn’t about their needs. Uncover in more profound and chalk what they require.

3. Completely Responsive

responsive design

Note that UI ought to be designed in such a way, to the point that the application is completely usable on various gadgets and mobile working frameworks.

Be it tweaking the media inquiries, JavaScript or CSS-every one of the issues identified with the show of the application on numerous mobile gadgets must be cooked capably.