title: ActionView::Template::Error (undefined method...) Works locally, but not on Heroku
body: <p>I didn't have trouble on previous code pushed to Heroku, but this last push has messed up. The only thing that has changed is instead of looping through each <code>student</code>, it's now looping through each <code>user</code>. </p>
  
  <h1><strong>Background</strong></h1>
  
  <p>The code works locally, but not on Heroku. The page that is raising an error on Heroku is a list (index) of all the students. What the code is doing is looping through all <code>Users</code> that have a <code>profile_type = "Student"</code>.</p>
  
  <p>For some reason it's trying to access the polymorphic association (profile) on a Student object, when the User object should be used instead.</p>
  
  <p><strong>Log from Heroku</strong></p>
  
  <pre><code>ActionView::Template::Error (undefined method `profile' for #&lt;Student:0x007f80c5552330&gt;):
  35:         &lt;tbody&gt;
  36:          &lt;% @students.each do |user| %&gt;
  37:           &lt;tr&gt;
  38:             &lt;td&gt;&lt;%= link_to user.profile.ivywise_id, student_path(user.profile_id) %&gt;&lt;/td&gt;
  39:             &lt;td&gt;&lt;%= link_to user.first_name.camelize, student_path(user.profile_id) %&gt;&lt;/td&gt;
  40:             &lt;td&gt;&lt;%= link_to user.last_name.camelize, student_path(user.profile_id) %&gt;&lt;/td&gt;
  41:             &lt;td&gt;&lt;%= user.email %&gt;&lt;/td&gt;
  app/views/students/index.html.erb:38:in `block in_app_views_students_index_html_erb__3704269538007702833_70095521176320'
  app/views/students/index.html.erb:36:in `_app_views_students_index_html_erb__3704269538007702833_70095521176320'
  </code></pre>
  
  <h1><strong>Application Code</strong></h1>
  
  <p><strong>student.rb</strong></p>
  
  <pre><code>class Student &lt; ActiveRecord::Base
    has_one :user, :as =&gt; :profile, dependent: :destroy
  ...
  </code></pre>
  
  <p><strong>students_controller</strong></p>
  
  <pre><code>def index
    @students = User.where(profile_type: "Student").order("last_name")
  end
  </code></pre>
  
  <p><strong>index.html.erb for students</strong></p>
  
  <pre><code>  &lt;% @students.each do |user| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;%= link_to user.profile.ivywise_id, student_path(user.profile_id) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to user.first_name.camelize, student_path(user.profile_id) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to user.last_name.camelize, student_path(user.profile_id) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= user.email %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;
        &lt;%= link_to "Edit", edit_student_path(user.profile_id), class: "btn btn-default btn-small" if can? :edit, Student %&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p><strong>user.rb</strong></p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    belongs_to :profile, :polymorphic =&gt; true
  </code></pre>
  
  <p><strong>What I have tried:</strong></p>
  
  <ul>
  <li>Double checked that all migrations from local/dev are in sync with Heroku</li>
  <li>Cloned the Heroku files to double check that they are running the same codebase</li>
  <li>Ran the <code>heroku restart</code> command</li>
  <li>Double checked and ran <code>heroku run rake db:migrate</code> to make sure everything</li>
  <li>Double checked the database to make sure all data and columns are the same</li>
  <li>I've checked on other machines and browsers; still the same issue</li>
  </ul>
  
  <p>Definitely frustrating... Thanks for any help!</p>