You do not need it.
In the form you can not specify these fields at all.
user_id is not needed there because the server at the time of creation can install it itself from current_user , its presence is not needed in the form of a comment. Consider: what will happen if the user through DevTools (or analog) user_id markup and specifies a different value in user_id ? Or do you intend to additionally check the user for honesty with an additional code? Isn't it easier to just not ask the browser a question if you know the answer in advance?
When you create a comment, overwrite current_user.comments , and the corresponding field in the created comment will appear automatically.
@comments.merge(current_user.comments).create(comment_params) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ # | | # наложение strong parameters
account_id ... depends. It may or may not be needed. In an amicable way, it should not, but it requires a little detail ... which you seem to have already implemented?
Judging by your form_for , you have a comments resource nested in accounts :
resources :accounts do resources :comments end
... then the comment creation URL of yours takes the form /accounts/{N}/comments . So, you also know the account on which the comment is left without explicit indication directly in the form (this information is recorded in the action-attribute of the form, the address to which the form makes the request).
And in the end, the algorithm for creating a new comment will be something like this:
@account = Account.find(params[:account_id]) @account. comments. merge(current_user.comments). create(comment_params)
... add error handling and authorization to taste.
... and what you are doing in new is completely irrelevant. Though Comment.new . This is only important if you want to hide some fields in the form.