In your Controller's #new and #create methods, scope the post to be owned by the current_user (or whatever other scheme you may be using for your logged-in-user management).
@post = current_user.posts.build
@post = current_user.posts.create(post_params)
Now your relationship will take care of getting the correct user in there automatically, whether it's in-memory or in persistence.
NB: If this doesn't appear to work, then you haven't built your relationships correctly, and you need to fix that before proceeding.