Ruby on Railsでデータベース検索結果を正しく表示したい

Ruby

[index.html.erb]<p style="color: green"><%= notice %></p> <h1>Houses</h1> <div> <%= form_with model: @house, url: "/search", method: :get, local: true do |form| %> <%= form.select :prefecture, [ ["北海道", "北海道"], ["青森県", "青森県"], ["岩手県", "岩手県"], ["宮城県", "宮城県"], ["秋田県", "秋田県"], ["山形県", "山形県"], ["福島県", "福島県"], ["茨城県", "茨城県"], ["栃木県", "栃木県"], ["群馬県", "群馬県"], ["埼玉県", "埼玉県"], ["千葉県", "千葉県"], ["東京都", "東京都"], ["神奈川県", "神奈川県"], ["新潟県", "新潟県"], ["富山県", "富山県"], ["石川県", "石川県"], ["福井県", "福井県"], ["山梨県", "山梨県"], ["長野県", "長野県"], ["岐阜県", "岐阜県"], ["静岡県", "静岡県"], ["愛知県", "愛知県"], ["三重県", "三重県"], ["滋賀県", "滋賀県"], ["京都府", "京都府"], ["大阪府", "大阪府"], ["兵庫県", "兵庫県"], ["奈良県", "奈良県"], ["和歌山県", "和歌山県"], ["鳥取県", "鳥取県"], ["島根県", "島根県"], ["岡山県", "岡山県"], ["広島県", "広島県"], ["山口県", "山口県"], ["徳島県", "徳島県"], ["香川県", "香川県"], ["愛媛県", "愛媛県"], ["高知県", "高知県"], ["福岡県", "福岡県"], ["佐賀県", "佐賀県"], ["長崎県", "長崎県"], ["熊本県", "熊本県"], ["大分県", "大分県"], ["宮崎県", "宮崎県"], ["鹿児島県", "鹿児島県"], ["沖縄県", "沖縄県"], ], include_blank: "都道府県" %> <fieldset> <legend>特徴</legend> <label> <%= form.check_box :feature1, {multiple: true} %> 身体障害者可 </label> <label> <%= form.check_box :feature2, {multiple: true} %> 知的障害者可 </label> <label> <%= form.check_box :feature3, {multiple: true} %> 精神障害者可 </label> <label> <%= form.check_box :feature4, {multiple: true} %> 発達障害者可 </label> </fieldset> <%= form.submit "検索", 'data-disable-with' => false %> </div> <% end %> <div id="houses"> <table> <tr> <th>建物名</th> <th>住所</th> <th>身体障害者</th> <th>知的障害者</th> <th>精神障害者</th> <th>発達障害者</th> <th>詳細</th> </tr> <% @houses.each do |house| %> <% okFlg = "可" %> <% ngFlg = "不可" %> <tr> <%= render house %> <td><%= house.name %></td> <td><%= house.address %></td> <td><%= house.feature1 == true ? okFlg : ngFlg %></td> <td><%= house.feature2 == true ? okFlg : ngFlg %></td> <td><%= house.feature3 == true ? okFlg : ngFlg %></td> <td><%= house.feature4 == true ? okFlg : ngFlg %></td> <td><%= link_to "Show this house", house %></td> </tr> <% end %> </table> </div> <% if session[:user_id] %> <%= link_to "New house", new_house_path %> <% end %>

コメントを投稿

0 コメント