Created
May 31, 2013 20:04
-
-
Save realdlee/5687610 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Country < ActiveRecord::Base | |
has_many :cities, inverse_of: :country | |
end | |
class City < ActiveRecord::Base | |
belongs_to :country, inverse_of: :cities | |
end | |
country=Country.first | |
city=country.cities.first | |
city.country.equal? country #=>true, but false without inverse_of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment