The code executes different method according to the environment, in Rails. In this way, you can show message only in development environment.
In Ruby, we can use
&&. And also
|| we can use. I researched about their difference.
I will introduce you several way to output sql result into a file with using psql.