I want to display a town name in my navigation, depending on the town I am requesting from the model. The following code works, but I am mixing logic in my view which I know is wrong and I haven't been successful in accessing the @town
instance variable from my TownsController
. Can someone lead me down the road to enlightenment in a situation like this? Should I be using a helper? How do I access it in my _header.html.erb
partial?
<li class="name">
<% @towns = Town.all %>
<% @towns.each do |t| %>
<h1><%= link_to "#{t.name}", '#', id: "logo" %></h1>
<% end %>
</li>