Other than params, the values received in the controller after skipping from the rails front are described.

Asked 2 years ago, Updated 2 years ago, 382 views

The params used in def create in the rails project is the singular name_params of the controller. Is this the rails specification?
I'm worried that I can't find such a configuration file.

Could you please tell me the details?
I would appreciate it if you could let me know if there is any other missing information.
Thank you for your cooperation.

ruby-on-rails ruby

2022-09-30 22:00

1 Answers

I think it's probably a controller generated by scaffold, but the singular_params of the controller is a method called the strong parameter, which is defined as the private method in the controller's file.

prevate
def hoge_params
  param.require(:model name).permit(:column 1,:column 2)
end

For example, in the above case, any parameters other than Column 1 and Column 2 specified in permit are ignored when POSTed.

The strong parameter is a feature introduced in rails4 and later to combat vulnerabilities such as mass assignment to prevent malicious parameter manipulation.


2022-09-30 22:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.