Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

WEBrick Server Hangs in Windows XP

Jun 29

I’ve been dealing with this insanely frustrating problem for a few weeks now. I do most of my Rails development on my Mac, but run instances on both Linux and Windows XP. XP has burned me until I won the battle this evening. I was able to install Rails through a manual process a while back. After getting Rails running on XP I struggled with the WEBrick server. The server would start and listen on port 3000, but when I made any request the browser would hang and so would the Ruby process.

After digging around this evening I stumbled across a link that talks about Winsock getting corrupted every now and then. While it doesn’t mention Ruby specifically I was desperate and decided to give it a try. I ran the following from my XP command prompt:

netsh winsock reset

and waited for a minute. It appeared that everything was reset so I started WEBrick back up and low and behold….it worked! I rebooted a couple of times just to verify that the fix was going to hang around and it sure did.

Read More

Personalized PDFs

Jun 27

I’m a sucker for personalization.  I’m not talking about having my initials engraved on a watch or golf ball, but things like ring tones, desktop backgrounds, and custom wheels on my Beetle (the important things ;) .  I view personalization as a form of self-expression and it also creates product appeal.  Jamie’s product line is a great example of this and it’s amazing to see the amount of interest personalization creates.

A couple of weeks ago I purchased a book on-line that came in PDF format.  I’ve done this a few times before, but was suprised to see a footer at the bottom of every page that said “Prepared exclusively for Dennis Baldwin”.  That may sound cheesy, but it gives the impression that someone at the company actually took the time to create the PDF for me.  We know that’s not the case, but it still adds just the right touch of personalization to keep me coming back for more.  The next time I want to order a book on-line I’ll definitely consider going back.  Below is a screen shot of my ultra-personalized PDF.

Read More

Rails Database Configuration on Fedora Core

Jun 27

A few days ago I was testing a Rails app on Fedora Core and ran into a slight problem.  You could actually call it a major problem since I was unable to talk to MySQL and instantiate any model objects.  Sometimes serious problems seem a little less serious when the fix is pretty straight-forward.  Lucky for me this was the case this time around.  When I started the application and tried to access my test controller I received the following error message:

Errno::ENOENT in TestController#index
No such file or directory – /tmp/mysql.sock

By default Rails looks for the mysql.sock in the tmp directory.  Since I used the default MySQL installation on Fedora this file was located in another directory.  I found the path to the file to be located at /var/lib/mysql/mysql.sock.  I updated the database.yml config file to include the proper location:

socket: /var/lib/mysql/mysql.sock

and everything started running perfectly.  A somewhat simple fix for a somewhat serious problem.

Read More

Using Ruby Console for Rails Development

Jun 25

Lately I’ve been using the Ruby console to test my Rails models and application logic. It’s a very handy utility that I’ve only touched the surface of and wanted to post a simple example.

Let’s assume that you’ve created a test application with a model named Contacts. The contacts database has the basic structure:

id int primary key auto_increment
name varchar(100)
email varchar(100)

Be sure to configure your database.yml file to talk to your development database. Now you simply need to initialize the Ruby console by going into your Rails application directory and running the following command:

ruby script/console

You should see Loading development environment >> printed to the console. Now you can create an instance of a Contact object:

c = Contact.new

and you’ll see the object printed to the console:

#nil, “address_line1″=>nil, “name”=>nil, “postal_code”=>nil, “address_line2″=>nil, “country”=>nil, “phone”=>nil, “state”=>nil, “email”=>nil}, @new_record=true

Now let’s assign some properties to it:

c.name = “Dennis Baldwin”
c.email = “dennisbaldwin@gmail.com”

After each property assignment you’ll see the value echoed to the console. We can now write the new contact to the database by issuing the following command:

c.save

You should see true printed to the console meaning the new contact was saved successfully. This whole process can be simplified with the following command:

c = Contact.create(:name => “dennis baldwin”, :email => “dennisbaldwin@gmail.com”)

Pretty slick and all of this is made possible through the ActiveRecord class.

Read More

Updating Rails to Version 1.1.2

Jun 22

I’ve been doing a fair amount of Rails development on OS X over the past year. During this time Rails has undergone a significant amount of development. When I initally installed Rails on OS X the current version was 1.0.0. This has been great until I recently ran into a problem with the acts_as_taggable plugin.

This plugin requires Rails version 1.1 or later due to some dependency on polymorphism. I decided not to dig into the details and figured it was time for an update. The update was much easier than expected and consisted of running the following command:

ruby gem update rails –include-dependencies

This downloaded all the necessary libraries, documentation, and I was immediately running on version 1.1.2. I restarted my app and tagging was instantly enabled. I’ll post more details later on how to actually use the plugin. It’s a minimal amount of work for the bang you get. But that seems to summarize my experience with Rails :)

Read More