Skip to content

Instantly share code, notes, and snippets.

@davidcelis
Created September 7, 2011 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcelis/1201945 to your computer and use it in GitHub Desktop.
Save davidcelis/1201945 to your computer and use it in GitHub Desktop.
class MyModel < ActiveRecord::Base
belongs_to :another_model
end
class AnotherModel < ActiveRecord::Base
has_one :my_model
end
my_model.another_model
# => AnotherModel.find(my_model.another_model_id)
another_model.my_model
# => MyModel.find_by_another_model_id(another_model.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment