Connecting a Windows VM to a Mac-based localhost Ruby on Rails site (Passenger)

Posted: January 20th, 2011 | Author: | Filed under: posts | Tags: , , , | 5 Comments »

Supporting Internet Explorer for your web app is a pain. At least, trying to test your Ruby on Rails (or other localhost-based site) in IE while developing on the Mac should be easy, given the prevalence of virtual machines. Right?? You’d think. However, trying to setup our front-end developer to access a local instance of Passenger running on Mac OS X from a Windows VM proved to be more of an issue than it needed to be. Adding to this, most of the top Google results for relevant keywords for this configuration made the process more overly difficult than it needed to be.

So, to help ease your pain in testing your Mac-based Rails site from a Windows virtual machine, here is an easy configuration for the three main VMs.

We need to do two main things:

  1. Trying to serve port-based or subdomain-based sites over to the Windows VM is going to be more challenging. Let’s make things easy – we’ll set the default http://localhost site for our Mac to our Rails site.
  2. We need to get the VM’s network to communicate with the Mac’s network correctly so that we can access this site.

On my team, we’re using Passenger on the Mac (running on top of the Mac’s base install of Apache). We’re using Passenger Pane to configure Apache easily. We also have this hooked into RVM, but that won’t be relevant to what we’re doing here. For the purposes of this post, I’ll assume that you have Passenger successfully serving a site that you can access via http://somedomain.local I’ll also assume that for whichever VM you’re opting to use, you have Windows installed and running in it.

** Do yourself a favor. Make sure that VM Ware Tools, Parallel Tools, or VirtualBox Guest Additions are installed – this ensures that the network connectivity will work as expected.

 

Let’s get http://localhost serving our Rails site

At the bottom of /etc/apache2/httpd.conf when using Passenger Pane, you’ll find the following configuration:

<IfModule passenger_module>
  NameVirtualHost *:80
  <VirtualHost *:80>
    ServerName _default_
  </VirtualHost>
  Include /private/etc/apache2/passenger_pane_vhosts/*.conf
</IfModule>

 

To make our Passenger site the default localhost site, go into passenger_pane_vhosts/, view the Apache config file for the site you want to be the default, and you’ll see something along the lines of the following:

$ cat yoursite.local.vhost.conf
<VirtualHost *:80>
  ServerName yoursite.local
  DocumentRoot "/Users/username/rails/yoursite/public"
  RackEnv development
  <Directory "/Users/username/rails/yoursite/public">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

 

Copy the lines from inside the VirtualHost block and paste them back into /etc/apache2/httpd.conf so that it looks like the following:

$ cd ..
$ sudo mate httpd.conf
# Added by the Passenger preference pane
# Make sure to include the Passenger configuration (the LoadModule,
# PassengerRoot, and PassengerRuby directives) before this section.
<IfModule passenger_module>
  NameVirtualHost *:80
  <VirtualHost *:80>
    ServerName _default_
	####
	DocumentRoot "/Users/username/rails/yoursite/public"
	RackEnv development
	<Directory "/Users/username/rails/yoursite/public">
	  Order allow,deny
	  Allow from all
	</Directory>
	####
  </VirtualHost>
  Include /private/etc/apache2/passenger_pane_vhosts/*.conf
</IfModule>

 

Restart Apache by going to System Preferences > Sharing and uncheck & recheck Web Sharing.

Also, if you’re using VMWare Fusion or Parallels, note the IP address that’s shown here.

Configuring VirtualBox

Let’s start with Virtual Box, which was the biggest pain to configure. Not because there’s a lot of work, but because they one critical detail doesn’t seem to be well known (most of the posts you’ll read online try to guide you through using the command-line network configuration tool). I should note that this was my first real opportunity to use Virtual Box, having only used Parallels and VMWare Fusion beforehand. It’s a little rough around the edges in a few places, but overall very impressive.

1) First, ensure that network settings for VirtualBox should be set to NAT – no port forwarding needed

 

2) Now, here’s what took a while to dig up: VirtualBox connects http://10.0.2.2 to the Mac’s localhost (thanks to this forum post) That is, just typing that into IE within the VM should connect you to http://localhost running on the Mac.

 

Configuring Parallels

1) For Parallels, you want to make sure that your VM is running on a Shared Network.

 

2) If you’re setup with this network configuration, you should be able to directly access the local IP address of your Mac, as shown in the System Preferences > Sharing screen:

 

Configuring VMWare Fusion

1) VMWare Fusion is much like Parallels. Configure your VM to “Share the Mac’s network connection” via NAT.

 

2) If you’re setup with this network configuration, you should be able to directly access the local IP address of your Mac, as shown in the System Preferences > Sharing screen, as with Parallels.

Hopefully, if you’ve made it to this point, for your respective VM, you have IE accessing your Passenger-based site. Success!

 

Hopefully, at least now you’ll be able to spend your time on all of the issues that poor users confined to IE are suffering through and get bug fixing quickly.


Resolving the MySQL Homebrew Install Issue

Posted: November 30th, 2010 | Author: | Filed under: posts | Tags: , , | 6 Comments »

We switched from using MacPorts to Homebrew for package management on our Mac OS X development machines. Recently, when building two machines and using brew to install MySQL on them, we ran into an issue where MySQL would only partially install and we’d get a mysql database with an empty user table. This was with mysql-5.1.52:

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from user;
Empty set (0.00 sec)

We tried a couple of things to solve this, but were not able to come up with a workable way to insert a root user, as you can’t create users when running with the –skip-grant-tables option.

I also tried the binary download from MySQL.com and hit the same snag.

After a couple of rebuilds and testing with a fresh install of Snow Leopard, we traced the issue back to the following error message from the MySQL setup script:

$mysql_install_db
Installing MySQL system tables...
ERROR: 1049  Unknown database 'mysql'
101121 19:21:38 [ERROR] Aborting
101121 19:21:38 [Note] ./bin/mysqld: Shutdown complete
Installation of system tables failed!  Examine the logs in
./data for more information.
"¦

Error 1049 proved to be the key to solving this. It led me to this MySQL bug report, which discusses that this error can be generated when the default temporary directory doesn’t exist.

Passing the /tmp temporary directory to mysql_install_db as a param seems to resolve error 1049 and allow us to get the default mysql system database setup with a working root user.

Most of the instructions for installing MySQL with Homebrew don’t mention any additional params needed, which leads me to believe this is something recent in the recent builds of MySQL. We didn’t have this issue when installing MySQL on our other Snow Leopard machines (which have 5.1.49). However, this is the sequence of commands that we found that worked for us – hopefully, this will help others hitting similar snags:

brew install mysql
mysql_install_db --user=mysql --tmpdir=/tmp
mysql.server start
#server must be running first
mysql_secure_installation

Hey, what caused that ActiveRecord::ConnectionAdapters::TableDefinition gooblygook on my table?!

Posted: November 24th, 2010 | Author: | Filed under: posts | Tags: | No Comments »

Maybe you’ve run into this, too? You’re taking a look at the tables generated by your Rails migration and you see this really odd column.

#<ActiveRecord::ConnectionAdapters::TableDefinition:0x10245fd78>

Here’s another look:

Yuck!

Searching the web didn’t turn up much in this case, so I thought I’d post what I found when figuring out the root cause.

See the issue in this migration?

No? I didn’t the first time I looked, either.

It’s the comma – at the tail end of the last column definition before t.timestamps.

This little typo doesn’t look like much, but it’s the cause of that wacky column.

Here’s what the table looks like when you run the migration with the comma:

And here’s what it looks like when you fix your typo:

Ah! Much better.

As for creating a migration to fix this, I just resolved the typo and dropped the column manually. It’s a little difficult to script this because the column name will be different in each database, so, it’s some variation of this (the part in bold on each database that the original typo ran on):

ALTER TABLE `friendships` DROP `#<ActiveRecord::ConnectionAdapters::TableDefinition:0x10245fd78>`;

Hope this helps someone else avoid wasting time on this!


Greetings from Ireland…

Posted: November 23rd, 2010 | Author: | Filed under: posts | Tags: , | 1 Comment »

When I last posted in June, we were heading to Europe to continue growing the FanGamb product. I’ve taken a bit of a vacation from blogging while I’ve been focusing on all that’s been involved in this.

I moved to Dublin in July and we’ve been rapidly rebuilding our team and the product. I’ll be able to go into more detail on the changes when the product re-launches in the near future, but things are going well. We’re having a great time in Ireland and have really enjoyed working abroad.

Since I can’t yet delve into the details of the move and transition, or the next version of the product, I’ll be focusing for a while on what it’s like to working abroad, and also some topics that I haven’t given as much “airtime” to in the past. Most of my posts to this point have been on various startup/entrepreneurship topics, which I’ve enjoyed writing about. A large part of my job, though, as VP of Product & Technology for Three Screen Games, has me deeply involved with both the technical product development and customer-centric product management efforts. These are petty broad areas and I look forward to exploring them further through future blog posts.

And of course, an update to the seed stage accelerator list is overdue – it’s amazing how this space has continued to grow in the last few months.

Anyway, it’s good to be back.


Exciting FanGamb Changes, Moving to Europe

Posted: June 24th, 2010 | Author: | Filed under: posts | Tags: , , | 6 Comments »

It’s been just over the one year mark since we started Three Screen Games and FanGamb. I left IBM on May 1, 2009, and we began the DreamIt Ventures program on May 18, 2009. It”s been an interesting and crazy year. We’ve learned much about what it takes to make a successful social game, and a successful startup. And we’ve positioned ourselves and our team for much greater success.

Part of what we’ve learned over the last year is that the industry of social gaming is still in its infancy and there is a host of new models to be experimented with. We have some exciting things in the works and as a result, will be moving to Europe later this summer to continue developing our product and business. We can’t yet share all of the details on why we’re making the move, but I’ll share more as soon as I”m able.

It’s certainly quite a change and not one that we expected a year ago, but we’re confident that it’s the best direction for our company and are extremely excited about the next phase of FanGamb. Personally, it should prove to be a valuable experience, working internationally and experiencing the European technology and startup communities.

So, if we”re moving to your part of the globe, or you’re just passing through, give us a shout! We’re very much looking forward to meeting new folks and saying hello. For everyone else, I’ll share the experiences through the blog and photos on my Flickr account.


Motivation – The Startup Advantage

Posted: June 22nd, 2010 | Author: | Filed under: posts | Tags: , , , | 2 Comments »

If you work with people, at some point you’re going to need to motivate them to do something you want. We’re not talking anything malicious, just getting stuff done. For most things, that’s always been the carrot and stick approach – if you do what I ask well, I’ll give you a carrot. If not, I’ll whack you with my stick. In essence – if you reward something, you’ll get more of what you want. If you punish something, you’ll get less.

And the bigger the carrot and stick, clearly, it would seem to make sense that the better the motivation derived from them. Because this system is ingrained in us, we see this everywhere.

 

To escape the status quo, everyone who works with or manages individuals should watch the below video, capturing the highlights of Dan Pink’s book Drive: The surprising truth about what motivates us. (Not only is it extremely interesting, it’s also a really great lesson in using whiteboards to make engaging videos :) ) Pink also gave a TED talk last summer.

Hopefully, you took a moment to watch it. For those of you that are reading on, here’s a quick summary:

When tasks call for cognitive skill over mechanical skill, larger rewards result in poorer performance. Pay people enough to take money off the table. And, emphasize the three key factors that lead to better performance and personal satisfaction:

1) Autonomy – self-directed
2) Mastery – getting better at their craft
3) Purpose – making a contribution

I found the video extremely interesting. While the carrot and stick approach is so intuitive to us, when you really stop to think about the tasks that we’re motivated to work on, Pink’s points hit home.

When you’re toiling away, in the bowels of some huge project, working on some small part that isn’t going to significantly make or break the big picture, are you really driven to do your best work? Compared with, if you are the “CEO of your job”, making a clear contribution.

This is one key reason why most corporations are at such a huge disadvantage to most startups when it comes to innovation. Having huge amounts of money and resources are fantastic, until you’re trying to get top talent to apply it to new problems. The main corporate driver is to maximize profit, and you work on small chunks of something larger that the end customer really doesn’t care about. Startups facilitate their people in maximizing purpose, making contributions. And if they don’t, they should be – startups aren’t just vehicles to accomplish the founders’ purpose. Startups are an opportunity for everyone on the team to work towards achieving something, a collective victory.

Also, since startups are one of the few places that have the capability to go against the status quo, to implement processes that would make corporate managers shiver in their cubicles, they’re also well setup to allow individuals the other two key factors – autonomy, to decide how best to achieve the task at hand, and mastery, to provide an opportunity to get better at their craft.

The Mark Pincus “Be the CEO of your job” example is a good illustration of this. So is the example that Pink uses in the video about Atlassian and their “FedEx Days”. Who knew how productive one day could be if you just gave your employees free reign to decide how best to make a contribution?

Jeff Atwood has a great post on how he’s applying these principles at Stack Overflow. Are you maximizing purpose and leaving your carrots and sticks outside? Or is your motivation based purely on dollars and thus is an ineffective sham? What’s working for you?