Skip to main content

strong_parameters

🔐 Secure with Strong Parameters

Strong Parameters protect your application from mass-assignment vulnerabilities by explicitly permitting allowed attributes. Define a private method in your controller to whitelist parameters for create and update actions. This pattern centralizes parameter filtering and improves maintainability.

class UsersController < ApplicationController
def create
@user = User.new(user_params)
if @user.save
redirect_to @user
else
render :new
end
end

private

def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation)
end
end