title: Trying to access attribute in join table Rails
body: <p><strong>Ok I think I have two problems which need to be fixed</strong></p>
  
  <p>I've got the following tables:
  <code>Student</code>, <code>Register</code> and a join table which displays the records that 1 register has many students in it, called 'Registers_Students' which looks like this: <img src="https://i.stack.imgur.com/snHUg.png" alt="enter image description here">.</p>
  
  <p>I had to create the <code>Register_Students</code> table via <code>rails g migration CreateStudentRegister</code>, which looked like this:</p>
  
  <pre><code>class CreateStudentRegister &lt; ActiveRecord::Migration
      def change
      create_table :registers_students, :id =&gt; false do |t|
      t.integer  :register_id
      t.integer :student_id
      t.boolean :present
      t.time :time_of_arrival
    end
   end
  end
  </code></pre>
  
  <p>Now, I want every register to have a number of students, and for every student, I want them to have a <code>present</code> status of true/false, and every student should also have a <code>time_of_arrival</code> time. 
  However, I have no way of accessing the <code>time_of_arrival</code> or <code>present</code> attributes, as I want to set them.</p>
  
  <p>The way I want to change these attributes for every student, is in the <code>register/show.html.erb</code> using the following code:</p>
  
  <pre><code>&lt;% @register.students.each do |student| %&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;%= Register.find(@register).present %&gt;&lt;/td&gt;         #Doesn't work
        &lt;td&gt;&lt;%= student.university_id%&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= student.first_name.titlecase%&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= student.last_name.titlecase%&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= Register.find(@register).time_of_arrival %&gt;&lt;/td&gt; #This doesn't work
        &lt;td&gt;&lt;%= student.time_of_arrival%&gt;&lt;/td&gt;                   #Nor does this
  
    &lt;/tr&gt;
    &lt;% end %&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>The reason I want it to be displayed in the <code>show</code> page, is so that the register can be edited with marking the student as either being present or absent, and also mark their time of arrival using a checkbox (That part hasn't been implemented yet, but if any of you guys know how to implement it, I'd love to hear about it).</p>
  
  <p>Thanks guys for any answers in advance</p>
  
  <p>EDIT: Added models</p>
  
  <p>Model for <code>Students</code>:</p>
  
  <pre><code>class Student &lt; ActiveRecord::Base
    has_and_belongs_to_many :registers
    validates :university_id, :length =&gt; { :minimum =&gt; 10}, #Checks that the University ID is 10 characters long
              :uniqueness =&gt; {:case_sensitive =&gt; false}, #Checks that the University ID is unique, regardless of case-sensitivity
          :format =&gt; { :with =&gt; /[wW]\d\d\d\d\d\d\d\d\d/, #University ID needs to be in the right format via regex
                       :message =&gt; "Needs to be in the right format i.e. w123456789"}
  
    default_scope :order =&gt; 'LOWER(last_name)' #Orders the students via last name
    attr_accessible :first_name, :last_name, :university_id
  
    def name
      first_name.titlecase + " " + last_name.titlecase
    end
  end
  </code></pre>
  
  <p>And this is the other model for the <code>Register</code></p>
  
  <pre><code>class Register &lt; ActiveRecord::Base
    has_and_belongs_to_many :students
    belongs_to :event
    attr_accessible :date, :student_ids, :module_class_id, :event_id
  end
  </code></pre>