title: Michael Hartl Rails Tutorial - Listing 11.36 (AJAX Unfollow) Error
body: <p>In <a href="http://ruby.railstutorial.org/chapters/following-users#sec-a_working_follow_button_with_ajax" rel="nofollow">listing 11.36</a> of Michael Hartl's superb tutorial, changes the unfollow form to use AJAX, but I keep getting the following error when I click on the "Unfollow" button:</p>
  
  <pre><code>ActionView::Template::Error (undefined method `model_name' for NilClass:Class):
  </code></pre>
  
  <p>The form, however, does work. If I click "Unfollow" I unfollow the currently displayed user. So it seems that @user in the form declaration is valid when the form is submitted:</p>
  
  <pre><code>&lt;%= form_for(current_user.relationships.find_by_followed_id(@user),
           html: { method: :delete },
           remote: true) do |f| %&gt;
  </code></pre>
  
  <p>but perhaps it's no longer available when the "Follow" form tries to load?</p>
  
  <p>I've tried at length to track this down but I can't figure it out, and I haven't seen anyone else post the same issue.</p>
  
  <p>Any clues?</p>
  
  <p>Thanks.</p>