Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I’ve a similar problem that brought me to this threat, so I thought sharing my solution here might be helpful to anybody.</p> <p>With <code>:remote =&gt; true</code> I got an normal HTTP Request to <code>http://localhost:3000/info/about?remote=true</code> instead of the wanted AJAX Request to <code>http://localhost:3000/info/about</code></p> <p>The fix was easy but hard to find!</p> <p><strong>In my HAML View:</strong></p> <p>WRONG Code that triggers HTTP Request</p> <pre><code>= link_to( image_tag("icons/information.png", :title =&gt; t('menu.info')), :controller =&gt; "info", :action =&gt; "about", :remote =&gt; true ) </code></pre> <p>OK-Code that triggers AJAX Request</p> <pre><code>= link_to( image_tag("icons/information.png", :title =&gt; t('menu.info')), {:controller =&gt; "info", :action =&gt; "about"}, :remote =&gt; true ) </code></pre> <p><strong>The only difference is {curly brackets}!</strong></p> <p>Funny though is that with the AJAX Request I get <code>info/about.html</code> rendered, without the layout file. Which isn’t a partial but is close to what Jan wanted. I was expecting <code>info/about.js.erb</code> to be rendered.</p> <p><strong>In InfoController</strong></p> <pre><code> def about respond_to do |format| format.html # renders ‘views/info/about.html.erb’ inside layout template on HTTP Request format.js# renders ‘views/info/about.html.erb’, without layout end end </code></pre> <p>-</p> <pre><code> def about respond_to do |format| format.html # =&gt; ‘views/info/about.html.erb’ inside layout template on HTTP Request format.js {render 'about.js'} # =&gt; renders ‘views/info/about.js.erb’ end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload