Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the coolest Ruby on Rails features, why choose it? [closed]

Before I asked this question I had a look through the search results for 'Ruby on Rails' here on SO. Couldn't find much, but the following (found on this page) amused me

Personally, I started using .html, moved onto php, tried ruby (hated it), discovered Python / DJango.. and have been happy ever since.

Now here's the deal. I have no personal intention of learning Ruby on Rails just yet, but it's the topic of a group presentation I am to do at the Uni (and my mates chose the RoR subject). People with a grudge against students asking homework-type questions should leave immediately.

This question is for RoR people who find it great. I hope to find those that claim RoR is the best (authors of the breathtaking testimonials to be found at RoR website). What makes RoR so outstanding? What would you like the youths of today to find out about it just before they leave the Uni with a degree. Try suggesting something that could root in their minds and perhaps navigate them the RoR way after leaving Uni.

Your answers will not only help my presentation, but could be the source of enlightenment for many.

like image 784
Peter Perháč Avatar asked Apr 05 '09 09:04

Peter Perháč


1 Answers

  • ActiveRecord's dynamic finders:

    Person.find_by_name_and_company_id('Jorge Luis Borges', 42)
    
  • rjs, writing javascript in ruby:

    page['element_id'].insert_html :bottom, :partial => 'comment'
    
  • ActiveRecord's scoping

    class Shirt < ActiveRecord::Base
      named_scope :red, :conditions => {:color => 'red'}
      named_scope :dry_clean_only, :joins => :washing_instructions, :conditions =>  ['washing_instructions.dry_clean_only = ?', true]
    end
    

calling Shirt.red will query the db with the "color = 'red'" condition the cool part, is that if you combine more than one scope eg:

      Shirt.red.dry_clean_only

it will build just one query, with all the conditions and joins necessary to satisfy both scopes.

  • ActiveRecord's Migrations, being able to manage db structure and data using active record, just like in the app's code, with minimal sql usage.
like image 82
Maximiliano Guzman Avatar answered Oct 21 '22 17:10

Maximiliano Guzman