title: Why Delete link doesn't work in this Ruby on Rails project?
body: <p>I am practicing this RoR tutorial project of Michael Hartl: <a href="http://ruby.railstutorial.org/ruby-on-rails-tutorial-book" rel="nofollow">http://ruby.railstutorial.org/ruby-on-rails-tutorial-book</a></p>
  
  <p>I am using Ruby 1.9.2 and Rails 3.1 on Ubuntu 11.04 with Apache and MySQL.</p>
  
  <p>I am here now: <a href="http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#sec:destroying_users" rel="nofollow">http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#sec:destroying_users</a> (where I have s list of users and a Delete link for each of them, me being the admin).</p>
  
  <p>This is the delete link which supposed to work:</p>
  
  <pre><code>&lt;%= link_to "delete", user, :method =&gt; :delete, :confirm =&gt; "You sure?",
                              :title =&gt; "Delete #{user.name}" %&gt;
  </code></pre>
  
  <p>But when I mouseover I see this: "localhost/users/2" (for example)
  And when I click on the Delete link it directs me to the user's profile. I don't get any confirmation window and no action is done (delete). It's like a link to their profile and nothing else.
  I am using Chrome but in Firefox is the same.</p>
  
  <p>This is what I have:</p>
  
  <p>1)the gem "jquery-rails" is installed</p>
  
  <p>2)applications.js (from app/assets/javascripts) has these lines:</p>
  
  <pre><code>//= require jquery
  //= require jquery_ujs
  //= require_tree .
  </code></pre>
  
  <p>3)application.html.erb (from app/views/layouts) has these lines:</p>
  
  <pre><code>&lt;%= javascript_include_tag :defaults %&gt;
  &lt;%= csrf_meta_tags %&gt;
  </code></pre>
  
  <p>In view source I see:</p>
  
  <pre><code>  &lt;script src="/assets/defaults.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;meta content="authenticity_token" name="csrf-param" /&gt;
    &lt;meta content="njPO91rB7p3EtTblD4jf4rkCVt+M76SKUt0rQhHc+qY=" name="csrf-token" /&gt;
  </code></pre>
  
  <p>4)in users_controllers.rb (from app/controllers) I have:</p>
  
  <pre><code> before_filter :authenticate, :only =&gt; [:index, :edit, :update, :destroy]
   before_filter :correct_user, :only =&gt; [:edit, :update]
   before_filter :admin_user,   :only =&gt; :destroy
  
   def destroy
    User.find(params[:id]).destroy
    flash[:success] = "User destroyed."
    redirect_to users_path
   end
  
   private
    def admin_user
      redirect_to(root_path) unless current_user.admin?
    end
  </code></pre>
  
  <p>5)in routes.rb (from config) I have:</p>
  
  <pre><code>resources :users
  </code></pre>
  
  <p>What is wrong with that Delete link?
  I've searched StackOverflow for answers but apparently I couldn't find one to suit my situation.</p>
  
  <p>On the same RoR project the follow/unfollow button using Ajax works just fine (can't post a second link here for now because I just registered to the SO).</p>
  
  <p>So, why the link doesn't work? Is it a Javascript problem or some other problem which I am not seeing?</p>
  
  <p>Thanks.</p>