Archive for the ‘Ruby’ Category

Issue and solution for upgrading Lighttpd from 1.4.8 to 1.4.11

Saturday, March 25th, 2006

After upgrading Lighttpd to 1.4.11 from 1.4.8 it was no longer working with my Ruby on Rails project saying it couldn’t find public/dispatch.fcgi. Well, it turns out they made this security fix which breaks relative paths typically used in lighttpd.conf: (more…)

Ruby + Rails + OSX Intel = Crazy Confusing

Saturday, March 25th, 2006

The Ruby on Rails scene for new users on the Mac has and continues to be pretty confusing! The version of Ruby that comes with the Mac isn’t suitable so you have to install a second copy and if you go to the getting started page at rubyonrails.org the first thing you see for OSX recommends building readline, ruby, fastcgi, lighty, and pcre from source. Fortunately (more…)

5 things Ruby on Rails has that Java doesn’t

Monday, March 13th, 2006

After listening to this weeks Ruby on Rails podcast where Geoffrey Grosenbach interviewed Bruce Tate, it got me to thinking about why Ruby on Rails appeals to me. For me as a Java person, the real appeal of Ruby lies in Rails and here’s why: (more…)

Ruby rdoc viewers still leave room for improvement

Friday, December 23rd, 2005

First a question, how do you go about looking up Rails or Gems API docs quickly while programming?

As a relatively new Ruby user I’ve just always assumed something was wrong with my Ruby installation because the following wouldn’t work: ri ActiveRecord::Base so I’ve always relied on running gem_server. Alas there is nothing wrong with my installation (more…)

Rails schema migrations… wow!

Friday, December 16th, 2005

Managing code versions, unit testing, building releases from a branch,
etc… are generally well understood processes where you’ll find
numerous organizations following similar practices.

Now go to the database schema and every company seems to have a
different home grown aproach to managing the database schema, migrating
changes, restoring older versions, etc.. Also, every solution I’ve ever
seen has involved updating the overall schema for fresh installations
as well as writing a migration SQL script for existing schemas. Not so
with Rails migrations!

I was blown away with this simple and elegant solution where you do the
migration to update an existing schema and then your overall schema
(for new installations) is automatically updated. This video demoing Rails migrations is a must see in my opinion!

Some other interesting reading on the subject: Robby on Rails, Buck Blogs, ScottStuff, API docs, and Gluttonous

Here's hoping Radrails takes off as a Ruby on Rails IDE

Tuesday, December 13th, 2005

In my
hunt for a good Ruby IDE I’ve tried almost all of the Ruby IDE’s I
could find. After using a variety of them I’ve lately been switching
between Radrails and JEdit with the Ruby plugin.
As a Java programmer I have a natural bias towards Radrails since it’s
based on Eclipse. The future of Radrails is especially promising as
they are planning to work in conjunction with the RDT
project where RDT will provide the core Ruby editing features and
TestUnit support, whereas, Radrails will provide the Rails specific
pieces such as editing RHTML, starting and stopping web servers, an
interface to script/generate, etc…

A really nice IDE is the
one thing I miss most when programming Ruby on Rails so here’s hoping
to the continued success of Radrails! Check it out if you’re looking
for a Ruby IDE, it’s still got a ways to go but it looks very
promising. They have a full installer (if you don’t have eclipse) that
incluces subclipse for subversion support which is a nice touch. If you’d rather watch than try they’ve also started creating videos.

Rails has some great generate commands and a whole lot more!

Tuesday, November 29th, 2005

If you’ve played with Ruby on Rails you’ve likely used script/generate to scaffold a simple CRUD application (including controller, views, helper, database fixtures, unit test, and functional test) as follows:

ruby script/generate DomainModel Controller

In my side project to learn Ruby I’ve grown very attached to using script/generate to put the rough pieces in place for me and then fill in the details. I really like that unit and functional testing are core to the approach instead of an afterthought or 3rd party library that takes a lot of work to integrate. I write much better functional tests in Ruby because it’s so easy, whereas in Java with the whole httpunit/cactus/cargo approach is a lot more work!

Anyhow, as I started playing with web services and email I was pleasantly surprised to discover I could also use the same simple approach to generate web services using Action Web Service and email integration with Action Mailer as follows. Need email confirmation when a user signs up for a newsletter as well as a system to send the newsletter:

ruby script/generate mailer Newsletter confirmation send

How about a web service to let others get the most viewed blog posts today or for the week:

ruby script/generate web_service BlogService get_top_blog_posts_today get_top_blog_posts_for_week

Need a controller that accesses a web service, why bother with generating client stubs that need to be maintained in source control when you can just start coding against the webservice:

class MyWeatherReport < ApplicationController
web_client_api :weatherforecast, :soap, “http://somesite/forecast/api”

def forecast
@forecast = weatherforecast.get_todays_forecast(@params['zipcode'])
end
end

The more I play with Ruby on Rails the more impressed I am. It’s a fairly flexible environment that really seems to have it all but it’s ideal use in my opinion is for greendfield projects that can do it right from the start. If you’re looking at porting your site from C++ to the latest greatest thing but need to keep a lot of old legacy code running against a poorly designed database schema it may not be the right fit.

That said I think Ruby on Rails really is the next great thing. I haven’t seen anything else that provides such a simple, elegant, and comprehensive solution to web development that you can get up and running on so quickly! It has ORM, MVC (supporting components, partials, page decoration), the best domain model validation framework out there, built in and very easy to use AJAX support, unit testing (with database test fixture loading), functional testing, AOP style interception, web services, email integration, you name it… (just don’t name static typing ;-)).

If you’re looking to learn more about Ruby on Rails I can’t say enough good things about Dave Thomas and David Heinemeier Hansson’s Agile Web Development with Rails, it’s one of the few tech books I’ve read cover to cover. It’s so well organized I generally find it quicker to lookup a solution in the book than to hit the web. Needless to say I’m really enjoying learning Rails!

Ruby needs "my" for variable declaration and scoping

Monday, October 31st, 2005

I’m still digging Ruby as I plug along over the weekends working on writing a Bliki as an exercise to learn Ruby and Rails.

One lesson many of us learned in the Perl days that seems not to have made it into Ruby was doing a “use strict” to require variable declaration. The biggest benefit being that it required you to declare and scope your variables before you could use them, especially critical in a mod_perl environment. This IMHO is a “very good thing” and saves a lot of headache and troubleshooting to find minor typos.

That said, Ruby does scope your variables nicely for you and is smarter than Perl was about it when not running strict, however, I totally agree with this quote from RubyGarden:


“One thing Perl’s my() gives you is a guarantee that you aren’t stomping on a given variable. For example, if I’m in a block of code in Perl and want to use a private variable I can just declare it with my() and never have to worry about whether a variable of that name existed previously. In Ruby, if you are inside of a block and want a private variable, you need to choose a variable name that has never been used before. I don’t want to have to hold the entire symbol table in my head!! What can I do?”

No language is perfect and just like Java has it’s flaws for my tastes, I’m finding Ruby does also. I wouldn’t be as excited about Ruby as a language if it weren’t for rails, gems, and rake but rails really is what puts it over the edge for me to make it a winning web development platform.

Ruby on Rails is my new favorite web stack

Saturday, October 22nd, 2005

I’ve been using Ruby on Rails on and off for personal projects and just finished working my way through Agile Web Development with Rails and Programming Ruby. Before I go on I would like to commend Dave Thomas and David Hansson for what is the most well written book on a web framework that I’ve read to date (and I’ve read a lot). Great work guys!

What Ruby on Rails does best is make web programming easy and quick. It provides a default project structure that’s sensible and ready to go out of the box. With it’s sensible defaults it only requires filling in configuration files when you want to do something out of the norm. It provides seamless integration between the domain layer and MVC layer (including validation), a powerful OR mapping layer (with native support for single table inheritance, trees, ordered lists, etc), provides a great unit and functional testing environment, and above all it allows you to override it’s sensible defaults when you need to do the complicated stuff. In other words it makes the easy things very easy while making the hard things still very doable.

That said there are a few things I don’t like but those have more to wih Ruby the language, than Ruby on Rails:

1. I miss being able to look at a method declaration and see what types of objects it expects.
2. I miss being able to do across the board powerful refactorings in IDEA or Eclipse. With Ruby’s duck typing you just can’t get the level of refactoring in an IDE as you can in a statically typed language.
3. I miss having to explicitly declare a variable because I occasionally make typos later on in the code and Ruby silently creates a new variable for me instead of telling me I’m using an undeclared variable.
4. My only complaint with Rails is that the erb templating language is intrusive just like PHP or JSP, I wish it were more like Tapestry where pages are pure HTML that can be filled with sample data that gets replaced with real data at runtime.

Despite those complaints Ruby on Rails has just barely edged out the mostly open-source Java stack as my favorite web development environment simply because I can work so much faster in it.

In search of a Ruby IDE

Tuesday, August 2nd, 2005

I’ve been looking for a good Ruby IDE as I continue to learn Ruby on Rails. So far the one that stands out the most is the Arachno Ruby IDE, it looks very full featured, relatively polished, and includes an Apache server (only on Windows) which you can run from the IDE.

The other two that looks interesting are:

1. The Mondrian Ruby IDE
2. RDT or Ruby Development Tools which is an Eclipse plugin, nice for us Java types.

I’ve also heard of a lot of people using TextPad for the the purpose or Vim and Emacs but those are a little too low level for my day to day programming taste.

If you’re doing any kind of development in Ruby, what are you using?

Update: I’ve started using the Ruby Plugin for Jedit which has nice IntelliJ like code completion features and API integration. It’s a bit of a hassle to install but otherwise very nice!