Skip to content Skip to sidebar Skip to footer

Rails Displaying Full Database Instead Of Of Attributes Only

I seem to have gotten things to a point in my rails app making sure that games and tickets are being created, but when I try and display them in the html.erb file, the whole databa

Solution 1:

Remove = from

<%= @g.tickets.each do |tick| %>

It should look like this

<% @g.tickets.each do |tick| %>

Solution 2:

The problem is with this line

<%= @g.tickets.each do |tick| %>.It outputs all the tickets that are associated witha game.

Remove = and the code should be like this

<table>
     <%@g.tickets.each do |tick| %>

     <tr><td><%= tick.id %></td>
         <% if tick.nickname.blank? %>
         <td> Available</td>
         <% else %>
         <td><%= tick.nickname %></td>
         <% end %>
         <td><%= tick.game_id %></td></tr>
     <% end %>
 </table>

Always be careful in using these Rails expressions. <% %> executes the output.whereas <%= %> prints the output.

Post a Comment for "Rails Displaying Full Database Instead Of Of Attributes Only"