What are Strong Parameters?
What are Strong Parameters?
Strong Parameters is a feature in Ruby on Rails that allows you to control and whitelist the parameters that are permitted for mass assignment. It helps prevent accidentally allowing users to update sensitive attributes or perform mass assignment attacks.
Here are the key points about Strong Parameters:
Strong Parameters allows you to explicitly define which parameters are permitted for mass assignment. This is done by specifying the allowed parameters in your controller actions.
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)
Can you explain the difference between ActiveSupport’s HashWithIndifferentAccess and Ruby’s Hash ?
Xem chi tiếtDoes Ruby Support Single Inheritance/Multiple Inheritance Or Both?
Xem chi tiếtExplain how you define Instance Variable, Global Variable and Class Variable in Ruby?
Xem chi tiếtĐăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.