Thursday, December 6, 2007

I'm bit by the bug

Okay, RoR is pretty cool. In about a couple of hours I have secured my login and activation. I found all of the places to customize and have done so, and I put in some pretty colors. It's amazing because when I was working in WebObjects I thought about how much I wanted to abstract things. I worked hard to make the WO version be as flexible as possible so that changes only were needed in one location and those locations were logically organized. The original developer and those continuing to extend rails obviously think along the same lines. Here's what I've been using so far and like:

Flash. Flash is really cool. You use it to pass messages from the controller to the next page displayed. It works as a hash , so you associate a string with a key. One standard is to use :notice as a key for messages to the user, and :error for error messages. What makes this awesome is that I can place <%= flash[:notice] %> in my page and whatever message gets passed will pop right in there. Wrapping a css class and span around that lets me control the format of these messages on every page. I set this up on my login page for the standard "username/password incorrect" message. Later, when I locked down the user's home page and sent a redirect to login, "you must be logged in to do that" showed up in the same spot, looking exactly the same! I think this is part of the fun that RoR gives a programmer. One of the best feelings of programming is when you what something to happen, you code something to happen, and it does. I know that sounds stupid, but ask a programmer and he will agree. What is even cooler, is when you want something to happen, you don't code it to happen, and it does anyway!

Another thing I like is the inheritance hierarchy. RoR was designed for maximum flexibility, and the inheritance structure provides it. Placing items in the superclasses provides for everyone. You want it to be specific? Put it in the subclasses. My only worry is that this won't be so easy with Models. I will have to see.

I did run into a problem with something I've had an issue with all along. The separation of migrations and model files seems so un-Rails like. I added on to the User class to allow a boolean to hold email preferences. For some reason the boolean wasn't getting set from the form. Eventually, I realized that I also needed to add it to some code in the model file. This is stupid. I should only have to declare my columns and properties in one place. I do not think that the benefit of backtracking migrations outweighs the ease and intelligence of single location editing of models. They're models! What language requires you to define classes in two places (okay, leave C++ out of this)?

Authentication is just about finished for now. Down the road I am going to want roles, but for now a simple Admin boolean will suffice. I should program up some more functional and unit tests, but I'm too lazy and I want to start playing with some Avatars. Mmmm... Character Creation is on the menu!

No comments: