title: pass object or object id?
body: <p>Given the following code, which <strong>enroll</strong> method is better and why? Or should this code be improved some other way altogether?</p>
  
  <p>My idea of "better" for the above basically boils down to 1) most philosophically correct (best practices) and 2) most efficient/performant.</p>
  
  <pre><code>Class Course &lt; ActiveRecord::Base
    has_many :enrollments # basically a join table
    has_many :students, :source =&gt; :user, :through =&gt; :enrollments
    def enroll_this_way(student)
      self.enrollments &lt;&lt; Enrollment.new(:course_id =&gt; self.id, :student_id =&gt; student.id)
    end
    # OR
    def enroll_that_way(student_id)
      self.enrollments &lt;&lt; Enrollment.new(:course_id =&gt; self.id, :student_id =&gt; student_id)
    end
  end
  </code></pre>