ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Best Practices for Ruby or Rails?


#1

Any favorite links for Ruby or Rails best practices?

Here’s a few that come to mind:

I just went through the AirBnb one. So AWESOME!

Lots of good Ruby tips, such as using named capture groups rather than $1, $2.

Like this:

/\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ "$3.67" #=> 0
dollars #=> "3"

Coding Standards for Modern Web Development
#2

This is the only issue I’ve had so far with the AirBnb guide:


#3

Just created a PR to my fork of the AirBnb Style guide, now the RailsOnMaui style guide:

https://github.com/justin808/ruby/pull/1


#4

I have two suggestions re: best practices for Rails:

  1. read lots of code - see how others are doing it
  2. following the guidelines set out in “Growing Rails Applications In Practice”
    (see https://pragprog.com/book/d-kegrap/growing-rails-applications-in-practice)

GRAPI advocates a minimalistic coding style that relies on the object-oriented basics in Ruby to structure and organize your code. For me, this has made a world of difference.


#5

This is useful:

http://guidelines.plataformatec.com.br/ruby.html

It’s a more concise, albeit less comprehensive version of the bbatsov Style Guide


#6

Hello, I have trouble integrating react_on_rails with my ROR application but It’s required ruby 2.3.0. How can I use react_on_rails gem with ruby 2.1.5 please help :slight_smile:


#7

@sankima Supposedly we work with Rails 3. If you really cannot make this work with Ruby 2.1.5, please post an issue to https://github.com/shakacode/react_on_rails.


#8

I just suggest reading a good code and watching how others do it (live, if you can, and video for the first time)

To make a long story short here https://www.sitepoint.com/10-ruby-on-rails-best-practices-3/ you can find a lot of useful info


#9

I’ve learned best from reading other people’s code and watching how other developers go about solving problems.

There are some good resources for Rails best practices here: https://github.com/ankane/rails-best-practices