1
我在我的控制器中有一個散列,一個視圖需要數據來顯示。在我見過的教程中,我學會了如何顯示哈希中的每個鍵值對,但是如何僅顯示我想要的鍵值對?如何顯示視圖中散列的特定鍵值對?
creating the hash in the controller
@app = {'title' => title, 'description' => description,
'active' => active, 'featured'=> featured,
'partner'=>partner
}
view: this displays each of the key,value pairs
<% @app.each do |key, value| %>
<li><%= "#{key}: #{value}" %>
<% end %>
tried this in the view just to display title, but isn't working
<% @app.select do |ind_app| %>
<strong><%= ind_app["title"] %>
<% end %>