Playing With Ruby On Rails
By Adrian Sutton
I’ve been developing a fairly dynamic website using Ruby on Rails for the past week and I’m really quite impressed. I’d had no experience with Ruby before so I had to learn a new programming language and a new webapp framework but I’ve gotten going without too many problems and am already at least as productive as I would be with J2EE (possibly more so).
Like most things though, it’s definitely very possible to create really awful looking code in RoR though most of the time the easiest way is very maintainable. I was quite surprised to see how big a mess the code created by the salted_login generator was. It appears that instead of putting in effort to keep the views to purely display, the author tried to minimize the amount of stuff in the views. Thus, instead of using HTML to create form elements which would have been simple, readable, maintainable and work in WYSIWYG editors, a helper function was used that output a complete table row with localized label and the form field. What’s worse though is that the helper function is about as readable as a perl script. It’s pretty simple to rewrite the view using plain HTML and then the helper function can be deleted entire without understanding exactly what it does. One would hope you don’t need to write code like that to achieve internationalization – this project doesn’t make sense to localize anyway.
There are a few other oddities – I keep having to use belongs_to relationships instead of has_one which is kind of odd but understandable when you think through it all.
The best part is having extremely few configuration files and the ones that are required are simple, easy to understand and rarely need to be edited.
The worst part is the lack of a good IDE, closely followed by the lack of cohesive documentation. The documentation you want is out there, you just have to be good with Google to find it. If you’re using OS X, I can’t recommend the RDoc dashboard widget enough as a quick API reference.