Adding a "latest post" section to blog
This is my original code to show all my posts and it works great.
<% @post.each do |post| %><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><% end %>
However, I also want to add a large div that shows my latest post. So I copy/paste the code above and changed the line <% @post.each do |post| %>
to the following:
<% @post = Post.last do |post| %>
There was no errors, but nothing showed up either. The reason I added this code is because I saw in a tutorial where the teacher went into rails c and typed @post = Post.last and could see the last post created. However, when I go into terminal and type it, I get the error:
No command '@post' found, did you mean: Command 'mpost' from package 'texlive-binaries' (main) Command 'rpost' from package 'suck' (universe)@post: command not found