<div id="likes"> <%= render partial: "likes" %> </div>
we render something here, but where is this partial?
usually when I render something with Rails it's a form or other code that exist
but what are we rendering here?
You can render any partial you want, Rails just provides a lot of helpful shortcuts when you pass in ActiveRecord objects. Here we're rendering one called
app/views/posts/_likes.html.erb. Since this is being rendered inside a Post view, it looks in the posts folder for the partial file although you could specify any folder you wanted.
You have to create that partial, it's not one that will be autogenerated for you, and we do this for organization of your code. You can reuse that partial in other places if you want and it will output the same HTML.
All the final code you can find here: https://github.com/gorails-screencasts/gorails-24-liking-posts
I actually haven't noticed that you created the _likes partial
I'll watch again, thank you for the quick reply!
Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.