title: How do i add an active class to a dynamic link?
body: <p>I have a sidebar that holds a list of posts. I need the corresponding post on my sidebar to have an active class. What i have currently does not work so what is the best way to do this?</p>
  
  <pre><code>def is_active?(path)
    current_page?(path) ? "active" : ""
  end
  
  &lt;% @posts.each do |post| %&gt;  
      &lt;%= link_to post.title, post, class: is_active?(posts_path) %&gt;  
  &lt;% end %&gt;
  </code></pre>