This style guide recommends best practices for newlines in Ruby code.
# bad
def method
issue = Issue.new
issue.save
render json: issue
end
# good
def method
issue = Issue.new
issue.save
render json: issue
end
# bad
def method
issue = Issue.new
if issue.save
render json: issue
end
end
# good
def method
issue = Issue.new
if issue.save
render json: issue
end
end
# bad
def method
if issue.save
issue.send_email
end
render json: issue
end
# good
def method
if issue.save
issue.send_email
end
render json: issue
end
# bad
def method
if issue
if issue.valid?
issue.save
end
end
end
# good
def method
if issue
if issue.valid?
issue.save
end
end
end