Archive for the ‘rails’ Category

Two great articles about ActiveMessaging

Tuesday, June 26th, 2007

Two great articles written by fellow TWers:

First off is
this article
describing the basics of a13g and some of the reasoning behind it, it’s written by fellow aussie Shane Harvie (currently working in the US).

Almost immediately afterwards Dennis Byrne writes this
great post
about integrating a Rails AJAX front end with an a13g messaging back end.

Good stuff.

Pre-fetching in Rails

Thursday, May 24th, 2007

Pre-fetching, firing off a query just to fill up the first level cache, is a classic Hibernate optimization. You can now also do it in Rails with
this plugin
. This fills a gap when outer join fetching becomes too complex or the cartesian product bites you (the result of outer joins is the cartesian product of all involved tables, which grows exponentially).

JRuby ready for prime time

Monday, May 7th, 2007

I’ve been hard at work lately on ThoughtWorks new product offering, ThoughtWorks Studios. Here’s a write-up of some of the stuff we’ve been doing lately with JRuby.

ActiveMessaging gets significant overhaul as well as support for WebSphere MQ and Amazon SQS

Monday, April 23rd, 2007

Andrew Kuklewicz just checked in a significant overhaul of ActiveMessaging he
describes the changes better himself
, but here’s a quick summary:

  • Automatic reload of processors and rails env in development mode (compare to how routes.rb gets reloaded in normal Rails).
  • Support for multiple connections and adapters per application.
  • Support for Websphere MQ (thanks to Sylvain Perez), Amazon SQS and JMS (via StompConnect).
  • Multiple subscriptions per poller process.

All the changes are documented on the wiki.

All in all with the addition of the WebSphere MQ and JMS support ActiveMessaging is certainly ready for prime time. Got an old mainframe system you want to expose to the web? Crank up that CICS MQ connector, get your flat file parsers ready and you’re set to go!

Truly superb work by Andrew and Sylvain!

Extending ActiveRecord::Base.find with new options

Monday, March 5th, 2007

I’m working on a new full text search index Ruby on Rails plugin that works completely in the database. This makes it possible to:

  • combine a full text query with other more structured criteria,
  • using LIMITs to do pagination,
  • sorting,
  • joins,
  • etc.

Right now you can do:

class Author < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :author
acts_as_full_text_searchable
end
@jon = Author.create!(:name => ‘Jon Tirsen’)
@post = @jon.posts.create!(
:title => ‘Hitta, the full text search plugin’,
:body => ‘Blah blah blah’)

@jon.posts.find(:all, :full_text_search => ‘hitta’)

So I’ve managed to extend ActiveRecord::Base.find to support a new option called :full_text_search.

Problem is:
I can’t seem to get alias_method_chain to work on ActiveRecord::Base.find.

It seems to be something about it being a class method or whatever. I’ve tried (anyone that has ever written an acts_as-plugin should be familiar with this terminology):

  • Putting the call to alias_method_chain in ClassMethods.
  • Putting the call to alias_method_chain in SingletonMethods.
  • ActiveRecord::Base.send(:alias_method_chain, ...).
  • And finally out of desperation I put the call into InstanceMethods.

Here’s the code:
http://hitta.googlecode.com/svn/trunk/hitta/lib/acts_as_full_text_searchable.rb

Wouldn’t it be so cool if Rails plugins could add options to find that gets expanded into for example :conditions and :joins?

Please help!

(Btw, “hitta” means “to find” in swedish.)

Bang that create

Monday, February 26th, 2007

This is probably an old trick to most of my readers, but anyways…

I can’t recall all the times I’ve set up test data in tests and the test has mysteriously not worked because failed validations refused to save an object. Chuck a bang on your “create” or “save” and you’ll get an exception instead!

Will mysteriously not work:

@blog.posts.create(:title => ‘Bang that create’)

Will throw an exception instead:

@blog.posts.create!(:title => ‘Bang that create’)

Sun on Rails

Friday, September 8th, 2006

Sun investing in JRuby is very cool. Having a Java implementation of Ruby isn’t a big deal for me but there’s two other reasons it makes me excited:

  1. Having a second implementation of a language is several times better than having just one. This second implementation will force Ruby to grow up. It may finally acquire some level of formal specification and it will require Ruby to move in a much more stable and planned way than before. This is going to be crucial as more and more start betting their businesses, jobs and careers on the technology.
  2. Is the Sun finally about to rise? I’ve seen several indications of Sun’s dynamism of lately. From cool hardware to making the right thing about it’s software line (Java and Solaris). Personally I don’t care whether Java is open source or not, but Sun should! Sun is a hardware company, moving towards their core competency while having a good plan of how to handle their peripheral offerings is going to be crucial for Sun to get their balance sheet back into black. Time to make a long-term investment in SUNW while it’s on the cheap?

I would not be surprised if we see a similar move from Microsoft soon. I mean, who doesn’t want to be on the marketing bandwagon and hype of the century (only 6.5 years into it but nevertheless).

Great BDD for Rails tutorial

Wednesday, August 30th, 2006

I’ve kind of put behavioral-driven development in the “interesting but a bit whacky”-bucket. Maybe something will get out of it but right now it’s not compelling enough for me to use it and certainly not to involve myself.

That said, this great tutorial by Luke Redpath did impress me. Those tests specs certainly look more better than normal Rails unit tests.

On the other hand, I am a bit cautious about doing super-detailed unit-testing of validations. I always get suspicious when the test code is orders of magnitude more lines of code than the actual application code.

Rubby on Rails

Monday, August 14th, 2006

They fight with the Javacs all the time and even though they are basicaly Camp this does not mean they do not kick ass! They have a religion that is called ‘Getting Real’ that costs 20 dollars and is based on Zen (like Rubby).

Hilarious!

Mailing list for RBatis

Thursday, May 25th, 2006

For any questions regarding iBatis for Ruby please use the development list of the iBatis project on Apache as described here. Archives are here. Please do let us know how you use RBatis and what features you would like to see the most.

When we get a real release we will set up a user support list specifically for the Ruby port.

Expect an early access release before RailsConf.

Speaking of RailsConf, I won’t make it this year but I will send my proxy Badrinath Janakiraman, an extremely talented developer from our India offices, to answer all your questions. He is currently placed in Chicago which is a bit closer than the other side of the planet where I am. (Sydney is truly an amazing place to live, but sometimes it just feels so far away from everything.)