Archive for May, 2009

Browser on VMWare Talking to Server on Host

One of the things I have been meaning to do for a while is set up VMWare so I can run a browser on WinXP that connects to a server running in OS X. I finally did that this morning. Here’s how:

1.) Follow the instructions here (Rob Sanheim, FTW): http://robsanheim.com/2007/12/11/creating-a-static-loopback-address-to-use-in-vmware/

2.) If you provide a different interface depending on the requested host name, then Edit C:\WINDOWS\system32\drivers\etc\hosts to point 10.0.0.100 (or whatever IP address you selected in step 1 to a hostname (for example local.mysite.com).

That’s pretty much it. I noticed that I had to restart IE for it to recognize the new hosts file changes, but otherwise it works like a charm.

No Comments

Ensure has_one Instance Exists

Sometimes you want to ensure that a has_one relationship always exists, even if the relationship is added after existing instances have already been created in your database. One way to solve the problem is to add an after_create and then have a rake task go through your database and create instances in each case where the has_one instance doesn’t yet exist.

I think the following is more elegant:

  has_one :thing
  def thing_with_create
    thing_without_create || create_thing
  end
  alias_method_chain :thing, :create

I can then access o.thing and it will automatically create it if it doesn’t exist.

What do you think?

,

1 Comment