Thing you want to do Extract all the information in the Item table Display database information in view file index.html.erb
Premise Item table contents info column! I want to display the saved contents in the info column
def index
@items = Item.all
end
When the index action moves Make @items contain all the information in the Item table.
<% @items.each do |item| %>
<%= item.info%>
<%end%>
<% @items.each do |item| %> @items ← Item table Contains all the information. Extract all the information from there and assign it to item (variable) one by one. <%= item.info%> Information saved in the info column <%= %> Information can be displayed by adding equality
Contents of Item table info Explanation 1 Explanation 2
View of index.html.erb Explanation 1 Explanation 2 (The information saved in the info column is displayed)
Recommended Posts