You shouldn't type it on your terminal, but in the rails console. On your terminal, type
rails console
, when that loads up, you can then do:post = Post.last
In order to only render for the last post, you wouldn't need the block, as such:
<% post = Post.last %><div class="col-md-4 col-sm-6 portfolio-item"><a href="#portfolioModal6" class="portfolio-link" data-toggle="modal"><div class="portfolio-caption"><h4><%= link_to post.title, post %></h4><p class="text-muted"><%= post.created_at.strftime("%B, %d, %Y") %></p></div></a></div>
By the way, it's not best practice to handle domain objects in your view. You could have this as an instance variable in your controller, as a Facade object if you have multiple objects.