Return to Snippet

Revision: 44745
at April 17, 2011 06:39 by abstraktor


Initial Code
#app/models/user.rb
class User < ActiveRecord::Base
 has_many :adresses
end

#app/models/adress.rb
class Adress < ActiveRecord::Base
 belongs_to :user
end

#irb
User.first.adresses.map do |address|
 if liste.include? address
  address.destroy
 else
  liste.push address
 end
end

Initial URL

                                

Initial Description
Remove all duplicate Adresses from first User.

Initial Title
remove duplicates from Relations

Initial Tags

                                

Initial Language
Rails