glassfish

Posted by Matt Williams

I've had a jruby rails app deployed to jboss for quite some time now. For grins and giggles I decided to try it under Glassfish today. After I deleted the old WEB-INF and .war file which were created by goldspike, it worked very easily. I'm surprised and tempted to replace the existing jboss install with glassfish, provided it has similar throughput. The footprint is definitely smaller and it is much easier.

You can find more about using glassfish with jruby at the jruby wiki.

Frozen

Posted by Matt Williams

You only see what your eyes want to see
How can life be what you want it to be
You're frozen... -- Madonna

The way to ensure that your production rails apps don't get messed up should the provider update gems is to freeze them. Moreover, it's a good idea to embed the gems/plugins needed for a particular application; it makes distribution of different versions easier, not to mention that you know exactly with which resources your code is working.

To freeze rails, you can either do a rake rails:freeze:gems, which uses the installed gems to freeze, or rake rails:freeze:edge which freezes off of the rails subversion repository. The last one allows you to specify a version to which to freeze. When it's time to thaw, rake rails:unfreeze will remove the frozen rails installation.

To embed gems in your application, use Gems On Rails, which will place gems into vendor/gems.

Modifying plugins for Rails 2.0

Posted by Matt Williams

I found myself having to modify one of my plugins, pretty_accessible_form recently; end_form_tag is no longer in rails. As the plugin draws forms, I needed to explicitly output </form>. I know that for most people there's use in no longer having the end_form_tag since it is added automatically, but there's a lot of plugins which might be broken as a result.

Find or Create

Posted by Matt Williams

I found myself recently typing code like:
1
2

foo = Bar.find(:first, :conditions => {:name => "Fred"}) || Bar.new(:name => "Fred")
As it turns out, there's a rails method for this: Model.find_or_create_by_COLUMN, where COLUMN is the name of the column.

class_attr_lookup

Posted by Matt Williams

I had a situation where I had configuration and/or control values in a database and I didn't want to have to read them over and over again, so I've created the following.