Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to render the AJAX response in RAILS
    text
    copied!<p>Ok, pretty simple question, I have working an AJAX method, what it does is that it searches in the database for specific information with a query. I can see in the Console that the query is being made, I can even see the "Post" in the Chrome Developer Console, when I click it I can see the HTML that I want to show, but i have no effing idea on how to render ir in the page.<img src="https://i.stack.imgur.com/bZdwz.png" alt="enter image description here"></p> <p>the :3000/ already has the html I want to show, but how do I update it??</p> <p>The way I am showing it is this... </p> <pre><code>&lt;%if not @itemsok.nil? @itemsok.each do |searches| %&gt; &lt;table&gt; &lt;tr&gt; &lt;td style="width:100px;"&gt;&lt;%= searches.first_item.description %&gt; &lt;/td&gt; &lt;td style="width:150px; font-size:30px;"&gt;&lt;%= searches.first_item_grade %&gt; &lt;/td&gt; &lt;td style="width:150px;"&gt;&lt;%= searches.second_item.description %&gt; &lt;/td&gt; &lt;td style="width:150px; font-size:30px;"&gt;&lt;%= searches.second_item_grade %&gt; &lt;/td&gt; &lt;td style="width:150px; font-size:18px;"&gt;&lt;a href="&lt;%= contribution_path(searches.id) %&gt;"&gt;Show&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>@itemsok is the variable where I save the items from the query.</p> <p>Thanks, I think I'm missing something very silly here. Sorry for my terrible english.</p> <p>UPDATE: The controller looks like this:</p> <pre><code>def index size1 = params[:size1] number1 = params[:number1] number2 = params[:number2] quiero = params[:quiero] tengo = params[:tengo] if (not number1.nil?) and (number1 != "") item1 = Item.find(number1) elsif not quiero.nil? quiero.strip! item1 = Item.find(:first, :conditions =&gt; ['lower(description) LIKE ?', "%#{quiero.downcase}%"]) end if (not number2.nil?) and (number2 != "") item2 = Item.find(number2) elsif not tengo.nil? tengo.strip! item2 = Item.find(:first, :conditions =&gt; ['lower(description) LIKE ?', "%#{tengo.downcase}%"]) end if (item1 and item2) @itemsok = Contribution.where("first_item_id = ?",item1.id).where("second_item_id = ?",item2.id).where("second_item_grade = ?",size1) respond_to do |format| format.html format.js 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