Rails foundationSort Order

Rails: Adding User to Comments

In this episode we show you how to add the context of a user to a comment. We need to be able to identify who made the comment on a post. We start by generating the migration file that will create the field where we will store the user_id. We then add the line in our create action in the comments controller to set the current_user.