Note that there are some explanatory texts on larger screens.

plurals
  1. POIf else condition not working properly?
    primarykey
    data
    text
    <p>This is my code in which i want to display the book details taken from the book table. </p> <pre><code>&lt;div class="tab-pane" id="computer"&gt; &lt;!-- Branch Computer --&gt; &lt;legend&gt; Computer Science&lt;/legend&gt; &lt;table class ="table table-hover"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; S.No &lt;/th&gt; &lt;th&gt; Book Name &lt;/th&gt; &lt;th&gt; Year &lt;/th&gt; &lt;th&gt; User ID&lt;/th&gt; &lt;th&gt; Owner Address&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;% @books.each do |b| %&gt; &lt;tr&gt; &lt;% if b.branch == "Computer Science"%&gt; &lt;td&gt;&lt;%= b.id%&gt;&lt;/td&gt; &lt;td&gt;&lt;%= b.book_name%&gt;&lt;/td&gt; &lt;td&gt;&lt;%= b.year%&gt;&lt;/td&gt; &lt;td&gt;&lt;%= b.user_id%&gt;&lt;/td&gt; &lt;!-- For displaying user details --&gt; &lt;% @susers.each do |s|%&gt; &lt;% if s.user_id == b.user_id %&gt; &lt;td&gt;&lt;%= s.address %&gt;&lt;/td&gt; &lt;%else%&gt; &lt;td&gt;&lt;%"Not found"%&gt;&lt;/td&gt; &lt;%end%&gt; &lt;%end%&gt; &lt;%else%&gt; &lt;td&gt;&lt;%"No any book of this branch"%&gt;&lt;/td&gt; &lt;%end%&gt; &lt;/tr&gt; &lt;%end%&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt;&lt;!-- End of Computer Branch--&gt; </code></pre> <p>But i dont knot what is going wrong here with the output?</p> <p>It is displaying like this. Take notice of the long line of each row. After editing i get this much. <img src="https://i.stack.imgur.com/PJhYt.png" alt=""></p> <p>Ok this is something abnormal going on in the terminal</p> <p><a href="http://pastie.org/5134510" rel="nofollow noreferrer">http://pastie.org/5134510</a> <img src="https://i.stack.imgur.com/EtrnO.png" alt="Notice the second row."> Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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