Something like this should work:
` <% if @portfolio.previous_post %>
<%= link_to "link_name",@portfolio.previous_post, class: "prev"%>
<% end %>`
This should work as well:
` <%= link_to_if(@portfolio.previous_post, "link_name", @portfolio.previous_post,
class: "prev") %>`
Once you provide a name for the url in addition to the url, everything seems to work.