der kl@mmeraffe | ruby. java. development.

a developers guide to the world of code

Sunday, August 06, 2006

Going on with Rails

Yesterday i started coding a small web app involving rss, mysql and stuff. Of course i chose Rails to check out how rapid and clean its possible to implement what i wanted to. I haven't that much with Rails till now, just a little testing. But the last to days (well, just for a couple of hours) it was possible for me to implement the database model + O/R mapping, the views, the rss-feed-aggregation-logic and user-management. Without even knowing the pitfalls or tricks in Rails i've done all of this in less than 4 hours or something (with my brain thinking how to do the design. coding was a joke!).
In Rails its fast to implement a web app because:

1. The ActiveRecord-Stuff.
Tell your app which database you use, generate models for the tables. Thats it for O/R mapping. When u change a field in the db, ActiveRecord dynamically changes its behaviour. And its extremely intuitive. Imagine a table "Customer". What if you want to find all of your customers? Right, just do
Customer.find_all
(or, nowadays:
Customer.find(:all)
). You want to change the customer-id? Type
customer.id = 1

Want to save the changes? Type
customer.save

There is nothing you have to code for the db-model in Rails.

2. Use of Ruby
I wanted to read rss-feeds. Of course, you can do this in every language imaginable. But with Ruby, its a sure bet that its extremely easy. I used "FeedTools":
@feedxml = FeedTools::Feed.open(feed.address)

now you can use the feed as a plain old ruby object.

3. no config
For some it may be a drawback to follow the conventions of Rails. Using plural-forms for tables isn't something everybody likes (including me), but when you create a "Customers"-Table you just have to generate your model "Customer" to dynamically access it. Same with actions in the controller. Create a method "login" and a rhtml "login". Now you can jump to localhost:3000/login and everything is done for you. Maybe for bigger apps thats not perfect but its great for prototyping.

4. No code bloat or bloated framework
The written code is always in Ruby, so its never to long, easy to read and to maintain. Rails has lots of stuff you will find handy but doesn't come with every latest technology every java developer have to fight with ;-)

I'll code along over the next couple of weeks, if the final app is something interesting i'll post it here :-)

add to del.icio.us | submit to digg | submit to reddit

1 Comments:

  • At 12:59 AM, Blogger Seb said…

    hey... i really like your blog. why don´t you visit mine =))

    just kidding... i do totally agree with dan. i havent done much in rails yet but looking at the code (especially at the amount of line) and the opportunities, e.g. building simple weblog within bloody 15 minutes (shown on www.rubyonrails)
    should get everyone excited by now!

     

Post a Comment

Links to this post:

Create a Link

<< Home