/ Published in: Rails
Remove all duplicate Adresses from first User.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#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