While often "good style" and idioms are language specific, some principles transcend language choice or personal preference. This is an attempt collect some of those practices in one place.
Extensive branching structures quickly become difficult to maintain. When you find yourself creating deeply nested structures, start looking for ways to break it down.
Consider the following code:
if current_user.signed_in?
if current_user.admin?
render "admin/landing_page"
else
render "user/landing_page"
else
redirect_to "signin"
end
Instead of nesting two levels, we can change up some of our logic and flatten out the control:
redirect_to "signin" and return if !current_user.signed_in?
(WIP)