Ruby on Rails View Rendering DB Info On Page

前端 未结 2 1287
离开以前
离开以前 2021-01-27 15:37

I am working on a project and currently working on one of the views which is a page of different categories. Everything is rendering correctly however it\'s also putting the db

2条回答
  •  时光取名叫无心
    2021-01-27 16:19

    when you use the tags <%= ... %> whatever is within the tags gets displayed on the page. In your current view you have

    <%= @categories.each do |c| %>
      
    <%= image_tag c.image, :class => "cat" %>

    <%= c.title %>

    <% end %>

    Which displays the entirety of whatever the loop returns which is where you're getting the display. Change the tags to be <% @categories.each do |c| %> and you'll be good to go.

提交回复
热议问题