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…
- 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???
6 thoughts on “Playing with Rails”
“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???”
Because I am not finished writing the book yet! 🙂
Ah! That explains it 🙂
Looking forward to it… What kind of animal will represent Ruby on Rails???
I do Rails all day and certainly don’t run script/server as root!
hm. If I don’t run it as root, all I get is this:
When I run it as root, I get the expected “people” index. Freaky. Perhaps some kind of permissions issue on the Rails installation?
The default installation of Ruby on Rails on the Mac OS X Tiger isn’t very good. I suggest that you follow this fix : http://tech.rufy.com/entry/46. Your life will be much easier after that.
There’s not a lot of books on Ruby on Rails. I agree with you that is strange that O’Reilly don’t have a book on it, when we know how much they that talk about it. The best book I know is http://www.pragmaticprogrammer.com/titles/rails/index.html. You should find almost all the answers in this book. It’s very complete.
Rails is still in development (not yet a 1.x version) and is difficult to get good documentation on it.
I am having trouble logging into MySQL. It started during my attempt to install Rails on Windows XP. Can anyone point me in the right direction for help?
Comments are closed.