MyRubyClass.reload!

August 8th, 2008 by Benjamin Wagaman.
Categorized as Ruby on Rails, programming.

Today I was writing some specs with RSpec, the Ruby BDD Testing Framework. In between tests, classes aren’t reloaded by default, so I went about try to figure out how to reload a class for certain tests.

Active Support defines a method on Class called remove_class. This provides half of the equation. The other half was to reload the class again. So, I wrote a method on the Object class that should handle most cases. Note, this may not work with namespaced classes, but it did the quick and dirty job of helping my specs to reload the class.

# Call this method like
# MyRubyClass.reload!
# or
# MyRubyClass.reload!('/path/to/file/my_class.rb')
class Object
def reload!(file = nil)
remove_class(self)
load(file || "#{self.to_s.underscore}.rb")
end
end

All I needed to do was then call this method when I needed to reload the class.

MyRubyClass.reload!

Upgrading to Rails 2.0

December 15th, 2007 by Benjamin Wagaman.
Categorized as Ruby on Rails, how to, programming.

With Rails 2.0 out now, it’s time to explore the new source. It’s hard to believe that it’s already been 2 years since I first checked out Rails 1.0 for the first time.

To update your Rails code, you can run
gem update rails

However, when I tried to run this command I was unfortunately greeted with a nasty error, when getting to update ActiveRecord.

Attempting remote update of activerecord
ERROR: While executing gem ... (Zlib::BufError)
buffer error

According to a Ruby Form post, I found a solution to the problem, updating ruby gems.

While you could run this line to update RubyGems to 0.9.5, I don’t recommend it.
gem update --system

Instead download rubygems-0.9.4, unzip it and then run
ruby setup.rb

This will allow you to continue to use Mongrel, because there are some incompatibilities with Mongrel running on Win32 with RubyGems 0.9.5. See the following:

and then update rails as you would expect.
gem update rails

Voila!

How to Migrate a Subversion Repository

December 11th, 2007 by Benjamin Wagaman.
Categorized as how to, programming.

While moving a subversion repository from one location to another is an infrequent task, it’s good to know and easy to do.

According to dot not

svnadmin dump /path/to/repo > reponame.dump
tar zcf reponame.tgz reponame.dump
scp reponame.tgz hostname:/path/to/new/repo

Then login to the new machine, and set up the new repo:

cd /path/to/new
svnadmin create reponame
tar zxf reponame.tgz
svnadmin load reponame < reponame.dump

Voila, you have moved your repository. Don’t forget to delete your old repository when you have made sure that you are correctly referencing your new repository. Thanks Scott for the help.

Introducing Rankaroo

February 2nd, 2007 by Benjamin Wagaman.
Categorized as Ruby on Rails, programming, technology.

rankaroo After many months of hard labor, I am emerging victorious with my first large-scale web application called Rankaroo. Rankaroo helps you organize your interests, share them with others, and connect with like-minded people. Everyone is a guru at something. Whether it’s that you know about ski lodges in the Alps or Greek Mythology or Hip Hop, whatever it is you have something to keep organized and share with the world. As we each share our interests we all benefit from mutual discovery.

In the traditional browser way of storing your favorites, you would put your favorites in a hierarchical set of folders and hope that you can remember where you put them later. A few years ago, some sites like del.icio.us introduced the idea of eliminating the hierarchy and using tags instead (basically words). But while this makes it easier to find things later, it’s relatively difficult to find a cross section of these tags, plus you basically throw out your normal grammar in favor of an alphabet soup of words.

Rankaroo is based strongly on the Connect-by-Clicks technology. Connect-by-Clicks is a system that turns simple language into connective tissue. It works as following.

You want to categorize the following web site. http://espn.go.com
Just type a simple phrase. For instance. espn sports news and scores

What Connect-by-Clicks does is creates interconnections between these words. So, later you could find this favorite by going to sports -> scores or espn -> news or espn -> sports -> scores.

While this is cool in itself, it’s not nearly as cool as when hundred of people are all doing the same. If my friend, Joe, enters a favorite on his basketball team and categorizes it by the phrase knicks basketball team scores, if I was searching for scores, I would find out about his basketball team.

You’ll have to experience the power of Connect-by-Clicks yourself to see what I mean.

First Date with Ruby

October 27th, 2006 by Benjamin Wagaman.
Categorized as Ruby on Rails, programming.

It’s been eight months since I met Ruby for the first time. I feel like I’m spoiled as a programmer now. But, honestly, sometimes I just take it for granted. I thought I’d take a mental trip back in time to the days when I was a PHP programmer and recall what I was amazed by.

December 2005
setting: sitting in front of a warm fireplace in Columbus, Ohio

“This book is so cool,” referring to Agile Web Development with Rails. “It’s so amazing that these high level operations are really all you have to think about. It’s like I can actually think conceptually and write code at the same time. These scaffold generators are cool, but I don’t really understand how they work. And what’s this iterator thing all about.”

March 2006
setting: sitting on a warm balcony in Orlando, Florida

“This book is so cool,” referring to Agile Web Development with Rails. “I wish I finally understood how all of this testing stuff works. Those Ruby on Rails podcasts are intense. Those people on that program are intense. What’s all this about meta-programming? Oh, well, one of these days. But until then, at least I’ve got an enterprise app under my belt. This would have taken me three times as long in PHP.”

July 2006
setting: sitting on a warm porch in Lewis Center, Ohio

“This book is so cool,”
referring to Agile Web Development with Rails. “These Ajax Scaffold Generators are so cool. I just built a time-tracker for my new company in a day. It’s nice that Rails has built in support for Ajax. I remember wondering in PHP how the heck would I do that all too often. I’ve got to finally read Rails Recipes. I just hate reading pdfs. But now I’ve finally got it in a book.

October 2006
setting: sitting in my warm office in Lewis Center, Ohio

“This book is so cool,”
referring to Agile Web Development with Rails. “I can’t wait for the second edition to come out on paper. I should really read that testing chapter again. I wish test fixtures weren’t so brittle. One of these days I’ll understand it better….”

a personal update

August 2nd, 2006 by Benjamin Wagaman.
Categorized as Ruby on Rails, personal, programming.

Okay, it’s been a while since I’ve written anything.  The last month has been pretty darn busy.  The Wagaman Clan migrated from Orlando, FL to Lewis Center, OH (in the Columbus, OH area).  We bought a house and I have started as a full-time freelance web developer.  Currently I am working on a Ruby on Rails project full time until at least half-way through September.  I just started on another short term contract today as well.

Thus far things have been going pretty well in the freelance arena.  I’ve been used to working in the “enterprise” arena, so it’s a little change of pace, but I like it.  To maintain my work records I am over half-way through developing a TimeTracker application in Ruby on Rails.  It keeps records for my work sessions, contracts, invoices, customers, and more.  It’s really cool developing custom software that you can use as well.  It’s teaching me a lot about Agile Web Development.

Well, that’s about all for tonight.  Tune in again, sometime…

A review of “Agile Web Development with Rails : A Pragmatic Guide”

May 21st, 2006 by Benjamin Wagaman.
Categorized as Ruby on Rails, programming.

Very few programming books have been revolutionary to me (OK, maybe it’s just this one. The authors of this book make it easy to understand the way rails works so well as an agile web development framework. Granted, after reading a few pages I had to go buy the Pickaxe book because I was a ruby virgin, but that’s all for the better. This is the kind of book that I would read all over again, just to pick up more.

I can’t wait to read the upcoming version 2 (on Rails 1.1)

Happy 1.1st Birthday!

March 28th, 2006 by Benjamin Wagaman.
Categorized as Ruby on Rails, programming, technology.
Rails 1.1

Rails 1.1

Rails, the web application framework we all love so much, is now on to version 1.1.

So, What’s new in Rails 1.1? Scott Raymond wrote an incredible article outlining the new features/changes.

Also, the up-and-coming Rails Recipes (well, actually it’s already released as a beta book on pdf) has a number of recipes that use Rails 1.1. I would say that I’ve read this entire book, but that means beta version 1. Since then Chad Fowler has released a ton of new chapters.

Rails Recipes

This is a must-buy for the newby railer, which is half of the rails audience. You can order the beta book from the Pragamtic Programmers. I need to buy stock in their company, because I like their books so much.

Next Page »