Rails Strong Parameters Values Adding

Adding Values to Strong Parameters in Rails

A memo about how to add values to strong parameters in Ruby on Rails with the Ruby language. This way, you can define values that cannot be added with form_tag, such as user_id associated with the User in a one-to-many relationship, and add the value when the create action is called. Example of adding user_id, def hashmodel_params params.require(:hashmodel).permit...

Shou Arisaka
1 min read
Nov 13, 2025

A memo about how to add values to strong parameters in Ruby on Rails with the Ruby language.

Example of adding user_id

def hashmodel_params
    params.require(:hashmodel).permit(:title, :content, :user_id)
end

This way, you can define values that cannot be added with form_tag, such as user_id associated with the User in a one-to-many relationship, and add the value when the create action is called.

def create
  params[:hashmodel][:user_id] = current_user.id
end

Share this article

Shou Arisaka Nov 13, 2025

๐Ÿ”— Copy Links