Skip to content

Instantly share code, notes, and snippets.

@jaredholdcroft
Created May 10, 2011 20:15
Show Gist options
  • Save jaredholdcroft/965285 to your computer and use it in GitHub Desktop.
Save jaredholdcroft/965285 to your computer and use it in GitHub Desktop.
Has_one problem
class Audit < ActiveRecord::Base
has_many :audit_items
belongs_to :auditor
belongs_to :contact
belongs_to :site
has_one :requested_by, :class_name => "Employee", :primary_key => "requested_by", :foreign_key => "id"
end
# This basically links to an Employee object but rather than employee_id it uses requested_by to store the id of
# the employee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment