2009-11-21

Moving to Gemcutter - keeping it clean

It seems the transition from the RubyForge Gems server (http://gems.rubyforge.org/) to the Gemcutter Gems server (http://gemcutter.org/) is nearly complete. The address of the former is now a DNS alias of the later.

If you're like me, you like to keep up-to-date, tidy and clean. In this case that means keeping my RubyGem sources list clean. Here's the quick and simple steps I took on my RubyGem installs to get everything cleaned up.

  1. Add Gemcutter Server - $ sudo gem sources -a http://gemcutter.org/
  2. Remove RubyForge Server - $ sudo gem sources -r http://gems.rubyforge.org/
  3. Remove GitHub Server - $ sudo gem sources -r http://gems.github.com

Note - if you get any errors about the server not being present in the cache, this may be due to a minor difference in the URL used to add the server and the one being used to remove it. For example, a trailing slash. Run sudo gem sources to see all of the servers and the exact URL that's configured.

2009-11-18

First Book Review

In the next week or so I'll be doing my first book review. I was sent a request last week by Packt to review the book Apache Maven 2 Effective Implementation. I'm looking forward to it, as I've been using Maven 2 for quite a while and I have plenty of opinions to share.

Full disclosure: I am a member of the Apache Software Foundation, a committer and PMC member of the Apache Harmony project and I have contributed a few patches to the Apache Maven project.

2009-11-06

Adding the accept-charset attribute to HTML forms with Rails helpers

An oft unused attribute of the FORM element of HTML is the accept-charset. I'm a bit of a encoding fanatic and someone pointed out to me that I wasn't setting this attribute on a Rails application that I'd hacked up. As I'm always interested in learning something new about Rails, I decided to try setting this attribute in my application.

When using the base FormTagHelper#form_tag, it's pretty simple.

<% form_tag(search_solutions_path, {:'accept-charset' => "UTF-8"}) do -%>
...
<% end -%>

Note the use of the quotes around the symbol accept-charset. This is required because a hyphen requires escaping to be used in Ruby symbols.

When using the RESTful FormHelper#form_for, it's a bit more complicated and not very clearly documented. After some debugging and trial & error, I figured out that you have to add another level of indirection to add HTML options.

<% form_for(@model, {:html => {:'accept-charset' => "UTF-8"}}) do |f| %>
...
<% end -%>