[RAILS] About the matter that was confused by "param is missing or the value is empty:".

background

Encountered while creating DM function Entry is a table for managing users who enter the chat room Room is an intermediate table for chatting

error contents

スクリーンショット 2020-10-25 19.00.47.png

Indicates that param does not exist in entry or the value of param is empty.

Resolved response

(1) Delete the require method of the strong parameter (2) Only the permit method is described

What is a strong parameter?

When submitting data from a form There is a security issue called "mass assignment vulnerability". For example, if an unauthorized request is made at the timing of data transmission, The data may differ from what is expected.

➡︎ A mechanism to prevent this vulnerability. By specifying the column name that allows registration and update in advance for each method, If unauthorized column data is sent, it will be discriminated and excluded from registration and update actions.

require method

Extract only the value associated with a specific key in params. You must specify the key name of the value you want to retrieve in the argument.

permit method

Get only the values of the allowed columns. The column name for that must be specified in the argument. If an unauthorized column exists in params, the column data will be treated as unacquired and ignored.

merge method

Join hashes (arrays with keys and values). For example, if there is a value that is not included in the received params but you want to include it together.

private method

Limit the invocation of each method. Therefore, it can be prevented from being recognized as an action by the controller.

Cause

It looks like the require method wasn't working. I wanted to call the data stored in the Entry table in the Room controller, When I specified it with the require method, it didn't work for some reason. Was it perceived as a duplicate?

References

https://stackoverflow.com/questions/47391168/param-is-missing-or-the-value-is-empty-in-nested-resource-method https://railsguides.jp/action_controller_overview.html#strong-parameters https://qiita.com/kazuki13070311/items/cdd4917af204e00de001 https://qiita.com/takuyama/items/d0f1aa073a8e2e7212f2 https://qiita.com/Takka_Log/items/32dae78d7e3892e7b051 https://qiita.com/ozackiee/items/f100fd51f4839b3fdca8 https://qiita.com/akiupdate/items/514b107090c16a2e1b47 https://qiita.com/zenfumi/items/694edc863527f91c8976

Recommended Posts

About the matter that was confused by "param is missing or the value is empty:".
About the matter that I was addicted to how to use hashmap
About the matter that tends to be confused with ARG of Dockerfile which is a multi-stage build
[Android Studio] About the matter that the design view is not displayed when using TextClock
About the matter that hidden_field can be used insanely
Determine that the value is a multiple of 〇 in Ruby