Beware if you are using has_many relationship the answer by JP will not work.
Extending the example:
class City < ActiveRecord::Base
has_many :shops
end
city = City.find(:name => "Portland")
then
city.shops.delete(city.shops[0])
Will delete from the DB!
Also
theshops = city.shops
theshops.delete(ss[0])
Will delete from the DB
One way to detach from the DB is to use compact or another array function like so:
theshops = city.shops.compact
theshops.delete(ss[0])
Will not delete from the DB
Also, in all cases delete_if Will not delete from the db:
city.shops.delete_if {|s| s.id == city.shops[0]}
Cheers!
Don't forget: If you are in doubt about these sort of things script/console is your friend!