title: Problem with link_to_remote in rails
body: <p>I'm having a consistency problem using link_to_remote in rails.</p>
  
  <p>I have 2 use cases of link_to_remote, and they generate different ajax.  I can't figure out why, and it is driving me crazy.</p>
  
  <p>Here is use case one...</p>
  
  <pre><code>&lt;%= link_to_remote "section-", :update =&gt; "sections", :url =&gt; {:action =&gt; :destroy, :controller =&gt; "sections", :id =&gt; @section.id } %&gt;
  </code></pre>
  
  <p>This generates the appropriate ajax (as below) and works as I expect.  Note that it picks up the :action param from the call and inserts it correctly in the ajax.</p>
  
  <pre><code>&lt;a href="#" onclick="if { new Ajax.Updater('sections', '/sections/destroy/1', {asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent('f5e50e62fafd118e4588b33c9571ea6eef864176')}); }; return false;"&gt;section-&lt;/a&gt;
  </code></pre>
  
  <p>I also have another instance where I use link_to_remote, but it generates incorrect ajax.  The use case is nearly identical, except the controller is different.  Either way, I wouldn't expect that to result in different ajax.  </p>
  
  <p>The call...</p>
  
  <pre><code>&lt;%= link_to_remote "question-", :update =&gt;"questions-1", :url =&gt; {:action =&gt; :destroy, :controller =&gt; "questions", :id =&gt; @question.id} %&gt;
  </code></pre>
  
  <p>The resulting ajax...</p>
  
  <pre><code>&lt;a href="#" onclick="if { new Ajax.Updater('questions-1', '/questions/1', {asynchronous:true, evalScripts:true, parameters:'authenticity_token=' + encodeURIComponent('f5e50e62fafd118e4588b33c9571ea6eef864176')}); }; return false;"&gt;question-&lt;/a&gt;
  </code></pre>
  
  <p>The obvious difference here is in the second arg to Ajax.Updater.  The :action param is missing from that path.  Why?  This results in broken code for me, but I can't understand why this is happening.  The link_to_remote calls are nearly identical.</p>
  
  <p>Please point me in the right direction.  Thanks.</p>
  
  <p>Below is my routes.rb file...</p>
  
  <pre><code>
  ActionController::Routing::Routes.draw do |map|
    map.resources :questions, :has_one => :section, :collection => { :sort => :post }
    map.resources :sections, :has_many => :questions, :has_one => :form, :collection => { :sort => :post }
    map.resources :forms, :has_many => :sections
  
    # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
    map.root :controller => "forms"
  
    map.connect ':controller/:action/:id'
    map.connect ':controller/:action/:id.:format'
  end
  </code></pre>