I played around with Rails a bit today. I contrived an excuse to attempt to create a generic "event management" application. I'm familiar with the basic requirements of the app, and have a need to have a generalizable app available to share with groups and departments on campus. And, I want to play around with Rails and ruby to get a feel for what it can do.
Well, I had better luck than Stephen did, but still not quite the magic "30 seconds from concept to production app" wonder that has been whipped up around Rails. I was following the "ToDo" howto and going off in my own direction. It didn't work too well, and I've just realized that's because the ToDo chapter is written to Rails 0.9, and I've got Rails 0.8.something installed. Apparently, Big Changes were involved going to 0.9. OK - so that should discount some of these issues/hangups.
At first, I was stumped trying to get Apache 1.3 (the stock install on MacOSX 10.4.2) playing with Rails. Thought I was following the instructions, but no joy. Gave up, and settled for the WEBrick server bundled with Rails. I got hung up for about 20 minutes because I didn't realize that ./script/server
needs to be run as root
. I could have sworn that wasn't required the last time I played with Rails. Once I figured that out, I got the free "hello world" page. Great. On to application creation... It would be cool(er) if the Hello World page gave me an interface to query any models/tables I've got configured. Kinda like D2W does...
I created a simple "event" model, with an "events_controller.rb", and associated "events" views. I used the rails scripts to generate controllers and scaffolds, and ran rake to make sure it all checked out. I spent a lot of time trying to figure out which controllers should be created (Event vs. Events, and Person vs. Persons vs. People) but once I finally got the right controllers and scaffolds set up (and trimmed the excess tests from the various abortive attempts), then it was pretty clear sailing. The scaffolded app isn't extremely high end - and as I've mentioned before, WebObjects DirectToWeb does a better job in some ways. But, the Rails scaffolded app is nice and clean, and looks rather straightforward to customize/extend. "Out of the box," it gives you a barebones index (list all records), an inspect page, an edit page (with appropriate widgets - textfields, textareas, date selectors, checkboxes...), an add/insert page, and a delete function. Pretty straightforward - but still no Search. wtf. D2w does that really really well, even letting you pick which field to search on, and providing the appropriate widgets to help you enter search parameters.
I haven't started looking at relations/joins - tying People to Events as either presenters or attendees - but that shouldn't be too difficult. So far, I haven't had to "write" any code, but invoking the various generation scripts should probably count - I didn't get functionality for free, since I had to teach it via generation. D2W gives you lots "for free" by reverse engineering a database schema automatically. Generated code is still code - it's just written by a script.
I'm going to read up on these before digging back in, though...
- manuals.rubyonrails.com
- documentation.rubyonrails.com
- Ruby on Rails manual - chapter 38: ToDo App
- Raible's notes on the RoR session at OSCON2005
- ... and any others I find...
I have to wonder, though... If O'Reilly is such a supporter of Rails, touting it as one of the Next Big Things, wtf isn't there a book in The O'Reilly Safari???