Some Best Practices in Ruby on Rails
Use ‘each’ instead of ‘for’
for elem in [1, 2, 3, 4, 5]
puts elem
end
[1, 2, 3, 4, 5].each { |elem| puts elem }
Use ‘Case/when’ conditions instead of lengthy “if” statements
puts "What is your task status?"
status= gets.chomp
case status
when ...
developerstack.hashnode.dev7 min read
Sabarish Rajamohan
Software Engineer | Ruby on Rails | .NET | Open Source Enthusiast
This is a nice set of best practices to have in mind while working with Rails Sanima Shrestha