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!

Howto – Get GoDaddy Rollin’ on Rails

Jul 26

I’ve done quite a few posts around getting my Rails app configured on GoDaddy’s servers. Let me first say that this is cumbersome, GoDaddy’s support is not the greatest when it comes to Rails, and the application is unbearably slow. I thought this was the case for only the server I was on, but it turns out a good friend of mine is having the similar (even worse) issues. Since I went through the entire configuration process again this evening I figured I would post the details for anyone interested.

Let’s assume you have a Rails app called myapp and you want to get it running on GoDaddy’s servers. The first thing you need to do is make sure your database.yml file is configured correctly under the production settings. If you’re running MySQL locally then you’re most likely using the local socket connection. For GoDaddy this needs to be changed to specify a host and port. Your config should look something like the following:

production:
adapter: mysql
host: mysql123.secureserver.net
port: 3306
database: mydatabase
username: myusername
password: mypassword

The main thing you need to note is the hostname of the MySQL server. This can be found in the GoDaddy control panel under MySQL. Once you get the database connection stuff configured it’s safe to go ahead and upload your application to the server. Just upload it to the webroot so the final URL will look something like http://mydomain.com/myapp/.

After uploading you’ll need to create a symbolic link to provide an easier URL to access. This may be something like http://mydomain.com/a. I’m not sure if this step is actually necessary, but let’s not deviate since I know it works! In the control panel click on the CGI Admin link and a new window will launch. You’ll see a section labeled Create Rails Symbolic Link. Click on the Show Rails Applications link and you should see a drop-down menu with your app name (myapp) in it. Fill out the text field to the right and call it “a” or whatever you want.

We’re getting closer. Now here are a couple of key issues to resolve. Be sure to modify your environment.rb file in /myapp/config/ and change the RAILS_GEM_VERSION to 1.0.0. The next thing you should do is make sure the path to the Ruby binary is set properly in /myapp/public/dispatch.cgi and the first line should look like #!/usr/local/bin/ruby. After making all these changes be sure to upload the files to the server. Finally, be sure to change the permissions on dispatch.cgi to 755. This only applies to Linux servers and I’m not sure if GoDaddy even supports Rails on Win.

That should be everything you need to get going. If you access http://mydomain.com/a/ you should be routed to the index page in the public directory. Now try accessing some of your controllers and see what happens.

When you’re ready for FastCGI check out this link: http://www.db75.com/new_blog/?p=242. I wouldn’t really call it fast because GoDaddy seems to be having problems managing this module. I’m optimistic they will step up their Rails game or else they’re going to lose a lot of customers to Dreamhost and TextDrive, which I’ve heard good things about.

Read More

Rails Constant and Global Variables

Jul 24

I was recently faced with a common problem that I wanted to share.  During development there are times you need to specifiy a global or constant variable that will be shared throughout the entire application.  In ColdFusion you would normally place something like this in Application.cfm.  In Rails I was uncertain how exactly to approach this.  At first I thought an application.rb file made sense, but the more I thought about it I decided to take advantage of the config files.

Since my global variable was one that would be consistent regardless of environment (dev, test, and prod) I decided to place it in config/environment.rb.  I placed this under the RAILS_GEM_VERSION constant:

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = ’1.1.2′
BASE_URL = ‘http://mydomain.com/’

Now referencing this in any view can be done similar to any other variable:

<%= BASE_URL %>

If you need to specify globals that are specific to environment then I recommend placing them in their appropriate config file:

/config/environments/development.rb
/config/environments/test.rb
/config/environments/production.rb

Read More

Killer Firefox Extension => FireBug

Jul 22

Out of all the Firefox extensions I’ve used my recent favorite is FireBug. If you do any sort of web development then you NEED to get this extension. It consists mainly of a console, debugger, and DOM inspector. These are much needed tools for web application development. My favorite feature of Firebug is the console where you can do live JavaScript authoring and testing. It reminds me a lot of Venkman. If you haven’t tried FireBug I highly recommend giving it a test drive.

Read More

Testing Rails ActionMailer without Connectivity

Jul 17

I was recently doing Rails development on my Mac without an internet connection.  Yes it can still be done, but there are certain things that are easily overlooked.  One of these was testing the ability of the application to send emails upon user registration.  Since I had no connection I was wondering if there was a way to emulate this functionality.

At one point in time I remembered reading about logging emails to a file and decided to dig around in my environment config files.  While digging through the test.rb configuration file I found the magic line:

config.action_mailer.delivery_method = :test 

When comparing this to my development.rb configuration file I realized this line was missing (intentionally).  I added the line, restarted the server, and voila, everything was configured correctly.  Anytime I used my custom mailer the email was routed directly to the development.log file.  I’ve found this to be a very useful mechanism for testing email functionality without needing an internet connection.  It’s also very useful for rapidly prototyping and testing functionality.

Read More

La Papusa

Jul 17

On a recent mission trip to help with Hope For Honduras a buddy of mine told me to try the papusas. When we were out in Tegucigalpa one of our hosts took us to a place that served them and I was extremely impressed. I had no clue how to spell papusa until this evening and was suprised to find a Wikipedia page for papusas. Now my next task is to find a place in Dallas that serves authentic papusas. Should be an interesting challenge.

Read More