#!/usr/bin/env ruby # This code comes from http://ruby-it.org/pages/4.6+-+Aggiorniamo+i+modelli+gi%C3%A0+esistenti # Check the page for copyright notice and explanations = Team.new (:name => "Fiorentina", :owner => "Della Valle", :balance => 9999) new_team.save existing_team = Team.find_by_name("Fiorentina") existing_team.owner = "Andrea Della Valle" existing_team. = Team.new (:name => "Fiorentina", :owner => "Della Valle", :balance => 9999) new_team.save existing_team = Team.find_by_name("Fiorentina") existing_team.update_attributes(:owner => "Andrea Della Valle") = Team.update(1, :name => "AC Milan")# diminuiamo alle squadre più ricche il bilancio Team.update_all("balance = balance - 100", "balance > 10000")