I finally made time to install Rails, planning on taking it for a test drive by making a Ruby on Rails version of the lightweight asset manager database we put together to store assets for Pachyderm.

Initially, I guess my install of Rails didn't have MySQL support (why on earth wouldn't that be included right out of the box?), and it kept barfing when it tried to connect. So, I installed or updated my MySQL kit via gem install mysql and it was able to build a simple scaffolded app to let me create a single record via the dynamically generated interface. That was pretty cool - automatically figuring out which widgets should be used, etc... Very WebObjects D2W.

But, it barfed on a field name in the table - it didn't like "type" at all. So, I renamed that field to "assettype" in my local copy of the database. Now I can create a record.

But, using the "list" action gives me an error:

ArgumentError in Asset#list

Showing /usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/templates/scaffolds/list.rhtml where line #13 raised:

too few arguments.

Extracted source (around line #13):

10: <% for entry in instance_variable_get("@#{@scaffold_plural_name}") %>
12:   <% for column in @scaffold_class.content_columns %>
13:     <%= entry.send(column.name) %>
14:   <% end %>
15:     <%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %>
16:     <%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %>

So, I'm kinda stuck. Rails seems REALLY promising, and everything I've heard/read about it makes me want to do a lot of stuff in it. I love the develop/test/deploy distinctions built in from square one. I love the unit testing built in. I love Ruby (but haven't really used it too much - it seems reminiscent of Lingo, but that's because Lingo is another Smalltalk derivative, via Hypertalk). Also, Rails just celebrated its first birthday, and was apparently received extremely well at OSCon.

But, the magical "it will build a wonderful app with no code" hype fell a bit short for me, at least initially...

Update: Turns out it was choking on a field named "format" in my "assets" table. Renamed the field to "dc_format" and it appears to be happy... Now that the Rails setup seems to work, and I've debugged the database schema conflict, it's actually very cool how it builds the dynamic app to manage records! Full "view", "edit", "add", "list" and "delete" actions, with a totally usable (but rough) UI. Now to dig in to see how to customize the layout of the dynamic app...

So, for Google's sake, Rails doesn't like these field names for tables: type, format - there may be others, but these are the ones that tripped me up so far...

Also, it's a bit odd that the default scaffolding app doesn't appear to provide a search function... I can list all records and page through them, but can't do a quick search? WebObjects D2W does that right out of the box, even generating "advanced search" forms at will. Looks like Rails has a plugin gem to do this (Search Generator Gem), but it's apparently a bit rough, and not included with Rails as a stock feature.