Files
brewery/app/views/places/index.html.erb
T

41 lines
1.0 KiB
ERB

<h1>Beer places search</h1>
<%= form_with url: places_path, method: :post do |form| %>
city <%= form.text_field :city %>
<%= form.submit "Search" %>
<% end %>
<%= notice %>
<% if @weather %>
<div>
<strong>
The current beer weather in <%= @city%>
</strong>
<p><%= @weather[:temperature] %> Celcius</p>
<img src=<%= @weather[:weather_icon][:image] %> alt=<%= @weather[:weather_icon][:description] %>>
<p><strong>Wind: </strong><%= @weather[:wind][:speed] %>, direction <%= @weather[:wind][:direction]%></p>
</div>
<% end %>
<% if @places %>
<table>
<thead>
<% Place.rendered_fields.each do |field| %>
<th><%= field %></th>
<% end %>
</thead>
<% @places.each do |place| %>
<tr>
<% Place.rendered_fields.each do |field| %>
<% if field == :name %>
<td><%= link_to place.send(field), place_path(place.id) %></td>
<% else %>
<td><%= place.send(field) %></td>
<% end %>
<% end %>
</tr>
<% end %>
</table>
<% end %>