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.

Gems Server

Posted by Matt Williams

Ever wonder how to view information about:
  • What ruby gems are installed?
  • Documentation for each gem?

rubygems has a built-in server which you can use to peruse the rdocs for a gem. To use it, type gem server at a prompt and then point your browser to href://localhost:8808.

It's pretty nifty.

Ruport Graphs

Posted by Matt Williams

ruport comes with an extension, ruport-util which adds, among other things, the ability to create graphs from reports. However, it's hardcoded to do line graphs. This is a code snippet which will (for png and jpg graphs, the others should follow) allow you to create other types -- it's just bar graphs, but the others would follow....

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.

Lots of Gems

Posted by Matt Williams

This isn't much of a tip, per se, but it's something I ran into today.

The way to having multiple rubygem repositories is to set the GEM_PATH environmental variable. This will allow you to use gems from more than one location -- something useful on shared servers.

Next, to figure out how to specify the version of rubygems you're using -- I've tried GEM_HOME and RUBY_LIB and my PATH, but it's not working properly on the shared host. More once I figure that one out.

Boxy Layouts

Posted by Matt Williams

This is a quick note on two ways of placing boxes around elements in the form.

The first is to use blueprintcss-rails(http://code.google.com/p/blueprintcss-rails/), a plugin which uses the Blueprint CSS framework, and add a box class to the elements.

The second is a little more involved (although more flexible). It requires installing Shaded Border, and adding the following methods to applicationhelper.js:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

  def add_to_options(options,option,value)
    if options.nil?
      options={ }
    end
    if options[option].nil?
      options[option] = value
    else
      options[option] = "#{options[option]} #{value}"
    end
    options
  end


  def boxed_layout(boxid = 'boxy_box_box', content_or_options_with_block = nil, options = nil, &block)
    e=""
    if block_given?
       options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
      options=add_to_options(options, :id, boxid)
       content = capture(&block)
       e = concat(content_tag(:div,content,add_to_options(options,:class,"sb")),block.binding)
    else
      content = content_or_options_with_block
      options=add_to_options(options, :id, boxid)
      e = content_tag(:div, content, add_to_options(options,:class,"sb"))
    end
    e << javascript_tag("border.render('#{boxid}')")
    e
  end
I'll make a plugin shortly.

acts_as_treemap issues

Posted by Matt Williams

In preparing for my presentation at Codemash, I discovered that the acts_as_treemap plugin is missing a method -- ruby-treemap has changed and as a result, it needs a accessor methods for bounds.

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.