Skip to content

Instantly share code, notes, and snippets.

@nicotaing
Created May 24, 2011 06:09
Show Gist options
  • Save nicotaing/988202 to your computer and use it in GitHub Desktop.
Save nicotaing/988202 to your computer and use it in GitHub Desktop.
Simple association
#app/model/user.rb
class User < ActiveRecord::Base
#Du coup tu peux appeler @user.address => Objet Address instancie
:has_one :address
end
#app/model/address.rb
class Address < ActiveRecord::Base
#Du coup tu peux appeler @address.user => Objet User instancie
:belongs_to :address
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment