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!

Problems Installing JSON Gem

Aug 17

I was recently playing around with Juggernaut, which is a very useful Rails plugin. If you’re building applications where the server needs to push data to clients then Juggernaut is worth a look. Under the hood it basically uses a Flash shim to open a persistent connection with the server and then events can be broadcasted from the server to all connected clients. This can be useful in chat applications and anything where near realtime collaboration is useful.

To install Juggernaut the JSON library is necessary. I tried installing the JSON gem by issuing the following command: gem install json. In doing so I received the following error message:

Successfully installed json-0.4.1
Installing documentation for json-0.4.1…
lib/json/editor.rb:977:50: ‘:’ not followed by identified…
Installing RDoc documentation for json-0.4.1…
lib/json/editor.rb:977:50: ‘:’ not followed by identified…

While it looked like JSON was successfully installed I came to find out that it wasn’t when I tried to start the Ruby push server: ruby script/push_server. You can see the details of the Juggernaut install here if you’re interested. After trying to install the gem a few more times I was ready to give up and move on. Luckily I decided to try a manual install and see if my results were any different. I opened a command prompt (on XP) and navigated to the JSON gem directory: C:\ruby\lib\ruby\gems\1.8\gems\json-0.4.1. In this directory was a file named install.rb so I issued the following command: ruby install.rb. This yielded the following output:

cd bin
install -c edit_json.rb C:/Ruby/bin
cd -
cd lib
install -c json.rb C:/Ruby/lib/ruby/site_ruby/1.8
mkdir -p C:/Ruby/lib/ruby/site_ruby/1.8/json
install -c json/editor.rb C:/Ruby/lib/ruby/site_ruby/1.8/json
install -c json/json.xpm C:/Ruby/lib/ruby/site_ruby/1.8/json

After this I decided to give the ole push server another go and it booted right up. I was able to run Juggernaut and successfully push data to multiple clients. I’m excited to see where this project will head and this definitely lends well to the whole Comet initiative.

Read More

Another Tip for Rails on GoDaddy

Aug 12

This tip is more of a hack than anything else. I recently ran into a problem with an app that had been running on GoDaddy for a couple of weeks. Then, out of nowhere, it completely stopped working. You couldn’t access any of the controllers without receiving the dreaded “Rails application failed to start properly” error message. I contacted GoDaddy’s support and their response was:

“Thank you for contacting customer support. Unfortunately we are unable
to provide third party scripting assistance via this forum. We apologize
for any inconvenience this may cause.”

What’s funny about this response is that it’s not the first time I’ve received the “it’s your problem not ours” reply. Of all the times I’ve received this message it HAS been their problem and not a scripting issue. At any rate, after planning around for a few hours I came to realize that the RAILS_GEM_VERSION fix I posted here was actually the problem. Remember that it worked fine and that GoDaddy must have upated something to cause it break.

So to fix the problem you need to either remove the RAILS_GEM_VERSION constant from environment.rb or comment it out. It’s ridiculous to think that this variable can break the entire application, but that’s what happened in this instance.

It’s good to see that GoDaddy has posted a page addressing common problems with Rails applications. You’ll see that it does mention the RAILS_GEM_VERSION update, but if that doesn’t do the trick be sure to try and remove it. It’s worth a shot and on more than one occasion it has worked for me (and others).

Read More

Ruby on the Rise

Aug 08

This should actually be a post about how Java leads the way, but if you’re involved with any sort of development you already know that Java is a dominant force. This is a total geek link (as is most of the stuff I post), but I was so fascinated with the results that I had to share. It’s TIOBE’s programming index that rates the top used programming languages based on different criteria. It’s interesting to note that Ruby is on the rise and PHP is ranked 5th.

http://www.tiobe.com/tpci.htm

I would attribute Ruby’s rise to Rails (say that three times fast) and I would have never touched it if Rails hadn’t come along. The most suprising thing to me is that my ColdFusion skillz are becoming obsolete. Yet I still love CF and Jeremy Allaire.

Read More

TextMate for RadRails

Aug 08

I’ve heard great things about TextMate and have yet to give it a try. It’s supposed to be the standard for building Rails applications on OS X, but I’ve been using this nice little tool called RadRails. I’ve been very pleased with RadRails and its tight integration with SubVersion, Rails Generators, and even the WEBrick server. I’m wondering if TextMate offers all this. If you’ve watched any of the Rails screencasts you’ve probably noticed a black screen with white, blue, orange, and green fonts. This is TextMate in all its glory.

At some point in the near future I plan on running TextMate on my Mac, but in the meantime Dr. Nic has posted a great TextMate theme for RadRails. I installed it this evening and really love the code coloring on the black background. It’s much easier on my eyes and I’m looking forward to a boost in productivity!

Read More

Rails ActiveRecord Validation Reference

Aug 06

I’ve found myself relying more and more on Rails validators.  I used to code funky validation logic in ColdFusion and even PHP to, for example, check to see whether or not a username already existed in the database.  While this can be done at the database level or in the application (where I used to do it) I prefer the Rails approach of handling it in the model.

The most beautiful thing is that validation methods are generally simple one-liners that let me focus on the presentation of the error message and not the logic behind it.  At any rate, the point of this post is share a link I’ve found very useful over the past few weeks.  Here’s a link to the ActiveRecord validation methods:

http://ar.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html 

Read More