title: Configuring routes with polymorphic associations in rails
body: <p>In my rails app I have user, school, and course models.  I have set up a polymorphic association so that users and schools have many courses as hostable, and the course belongs_to hostable.  My routes look like this:</p>
  
  <pre><code>  resources :users do
      resources :courses
    end
  
   resources :schools do
     resources :courses 
   end
  </code></pre>
  
  <p>The show in my school controller looks like this:</p>
  
  <pre><code>def show
    @school = School.find(params[:id])
    @user = current_user.schools.find_by_user_id(params[:user_id])
    @title = @school.school_name
    @hostable = @school
    @courses = @hostable.courses
    @course = Course.new
  end
  </code></pre>
  
  <p>The courses partial that renders in the school and user show page looks like this:</p>
  
  <pre><code>&lt;div id="courses"&gt;
   &lt;% @courses.each do |course| %&gt;
    &lt;div class="course"&gt;
  &lt;%= simple_format course.title %&gt;
      &lt;%= simple_format course.description %&gt;
    &lt;/div&gt;
   &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Right now I only have the school view configured to simply list the course title and description.  What I want to do is list all of the school's courses on the school's show page, and instead of only showing the text of the course title, I want the course title to be a link which re-directs to the course's page.  Any suggestions?</p>
  
  <p>Thanks.</p>