In the last few years I’ve found two situations where comments aren’t really comments - here’s one.
I prefer Postgres to SQLite for Rails projects. I also like to avoid the initial
bundle on project creation. So I made a
~/.railsrc file that looked like this,
--skip-bundle -d postgresql
A few weeks ago I wanted to ditch the postgresql bit, but leave a comment showing how to restore it. So I changed it to something like this:
--skip-bundle # Uncomment the following line to use postgres in new projects # -d postgresql
I saved it, created a new project, and it still generated postgress-based Rails projects. What?
The command line showed what was really being run. Rails takes the contents of the
.railsrc file it finds, concatenates the lines together, and passes the whole thing to the Rails command line.
So, when I ran
rails new project_name
.railsrc file, I was really executing…
rails new project_name --skip-bundle # Uncomment the following \ line to use postgres in new projects # -d postgresql
Yeah, see that? I’m still passing
-d postgresql as one of many named arguments. “Commenting” the line didn’t really do anything. I had to make it more abstract (“dash then the fourth letter”… type stuff) to work “correctly.”
So, lesson; starting a line in a
.railsrc file (and perhaps others) with a hash doesn’t do much of anything. It just, well, throws a hash into the options.