I used the scaffold generator to generate a title (string) and body (content) so I can create ‘posts’.
When I generatored this model, is there a way I can have <%= posts.id %> so:
<% @posts.each do |post| %>
<div id="<%= posts.id %>">
<%= post.title %>
</div>
<% end %>
Update
Apologies for the confusion. What I meant to say is when you generate a model, does it come with an ID?
You are referencing ‘posts’ which doesn’t exist.
@posts is a collection of posts, so there’s no id on that either.
Each post will have an id though, so you can do post.id inside that block just as you have post.title (singular)