Posted by Doug
Thu, 02 Mar 2006 15:00:00 GMT
If you’re a one hacker shop doing Rails development it’s no big deal to store all your database usernames and passwords in config/database.yml. When you’re part of a team all hacking on the same code it becomes a little more complicated. This is my humble solution that I’m sure dozens of folks have already thought of.
This is the ugliness of the default generated config/database.yml:
development:
adapter: mysql
database: rails_development
username: root
password: my super secret password
So let’s say we have one master config/database.yml checked into svn and each developer modifies the file with their own username and password. Now we’re stuck with the risk of each developer accidentally checking in their working modification of that file. Also, do you really want your production database username and password stored in svn?
This morning I had an epiphany. Thanks to Rails 1.0 we can embed ERB into the config/database.yml. Usually I only think of doing things like outputting environment variables and the like. It occurred to me this morning you can put arbitrary Ruby inside the config/database.yml.
First we have to restructure the yaml:
login: &login
username: defaultuser
password: defaultpassword
development:
adapter: mysql
host: localhost
database: foo_development
<<: *login
I learned that syntax from the Typo guys. It basically lets you name blocks and then reuse them later in the yaml file. You probably see where I’m going with this…
login: &login
username: defaultuser
password: defaultpassword
<%= file = File.join(RAILS_ROOT, "config", "dblogin.yml")
IO.read(file) if File.exist?(file) %>
development:
adapter: mysql
host: localhost
database: foo_development
<<: *login
What this will do is insert the contents of config/dblogin.yml if it exists. This allows each developer to have a separate file in their working dir with their personal db login information. Further, you can svn propedit svn:ignore config to tell svn not to complain about the unknown file dblogin.yml.
Posted in Ruby on Rails | Tags Rails, Ruby | 8 comments
Posted by Doug
Wed, 01 Mar 2006 22:51:06 GMT
I gave a “bootcamp” style presentation today at work on Test Driven Development on Rails. I was struggling to figure out what tool to use to actually compose and give the presentation. S5 is a tool from Eric Meyer that uses XHTML, Javascript, and CSS to make a web-based presentation. It’s really cool. Rather than all the typing needed to write valid XHTML, I wrote a Ruby script to convert Textile to S5. I’ve included the Ruby code needed and my TDD presentation.
BTW, you can view the live presentation here
Posted in Test Driven Development, Ruby on Rails, Programming | Tags Ruby, testing | 8 comments
Posted by Doug
Fri, 24 Feb 2006 16:49:18 GMT
My hot company, Rosetta Stone, has bought me a gorgeous Samsung t809. The display on this phone is stunning. I like the size and weight. I like the auto-lock keypad. What I don’t like is that it doesn’t support the syncML Bluetooth profile. This means it’s incapable of working with Mac OS X’s iSync.
I was just about to throw in the towel and swap the phone out for an uglier Motorola V360 when David Nanian (of Super Duper! fame) gave me an idea. I had just gotten off the phone with Samsung’s tech support. The end of that conversation was, “We have no phones for T-Mobile that work with a Mac.” When I told that to David he reminded me that any GSM phone will work with T-mobile if you just plug in your SIM card.
That got me thinking. I still have my Sony Ericsson T637 that has always worked marvelously with iSync. Why not simply use my SE T637 as a very clumsy conduit between my Mac and my t809? It works pretty well. Here’s my steps:
- Power down t809, remove T-Mobile SIM card.
- Power down SE T637, insert T-Mobile SIM card, power back up.
- Use iSync to load phone numbers onto SE T637.
- Use the T637 to copy phonebook out to the SIM card.
- Power down SE T637, remove T-Mobile SIM card
- Replace SIM card back into t809
- Power up t809 and feel the love!
There are two things that make this work fairly nicely. The first is props to Sony Ericsson for first-off working with iSync; second for nicely allowing me to copy all my phone numbers out to the SIM card. Second, while I can copy the numbers from my SIM card into the t809’s memory it easily allows me to use the numbers directly off the card.
Besides the umpteen steps needed to complete this process, all is not a bed of roses. The biggest limitation of this process is the extremely simplified phonebook on the SIM card. It’s basically one name, one number. So instead of getting one contact with both a cell phone and a home phone, I get “Joe Somebody/Home” and “Joe Somebody/Cell” and “Joe Somebody/Work” .... I may grow tired of that, we’ll see. For the time being, I’m happy enough with this hackery.
Tags Ericsson, iSync, phone, Samsung, Sony, T637, t809 | no comments