#!/usr/bin/env ruby # This code comes from http://ruby-it.org/pages/4.5+-+Otteniamo+i+record+dal+database # Check the page for copyright notice and explanations = Team.find(1) #team conterrĂ  l'oggetto Team con id uguale a 1 teams = Team.find([1,2,3]) #teams sarĂ  un array di Team team = Team.find(:first) #prima squadra per id teams = Team.find(:all) #array contenente tutte le = Team.find(:all, :conditions => "balance > 1000", :order => "name") team = Team.find(:first, :order => "balance") teams = Team.find(:all, :order => "name", :limit => 10) = Team.find_by_name("Milan") inter = Team.find_by_owner("Massimo Moratti") richest = Team.find_all_by_balance(1000000) = Team.find_by_name_and_owner("Juventus", "Giovanni Cobolli Gigli") romane = Team.find_all_by_name_or_owner("Lazio", "Franco Sensi") = Team.count("balance > 1000") #torna un intero b = Team.exists?(:name => "Milan") #torna un