Journal of a Geek

Ruby on Rails and SQL are great!

leave a comment »

Last night I was working on the newspaper's website, and I wanted to add an anchor to the end of one of the dynamic links Ruby on Rails was making for me. I searched for a few minutes and found out the key was just adding :anchor => "anchor name" to my link code. This is part of the reason I like writing in RoR so much. In any part of the program that is helping you generate a HTML tag, to set an option you just do :attribute => "value" inside your helper tag. This is so much better than memorizing some crazy syntax.

The model queries are great to. You can either use RoR's syntax for really simple queries. For instance, Comments.find(:all, :limit => 5) will find the first five comments in the comment model. If you need a more complex query, it let's you enter SQL statements. If you compare this to something like ASP.NET it's so much easier. In ASP it takes about 8 lines of code to generate that same query.

Speaking of SQL statements, I hadn't worked with straight SQL for about a year now. Last night I was writing a query to find the articles in the newspaper with the most comments. It helped remind me of how simple the SQL syntax is.

Advertisements

Written by Ryan Farnell

June 8, 2006 at 5:10 pm

Posted in Web Development

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: