Skip to content

Instantly share code, notes, and snippets.

@realdlee
Created May 31, 2013 20:04
Show Gist options
  • Save realdlee/5687610 to your computer and use it in GitHub Desktop.
Save realdlee/5687610 to your computer and use it in GitHub Desktop.
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