CodeNewbie Community

Alton
Alton

Posted on

How do Ruby on Rails "strong parameters" work?

Why does the controller spit out an error if I have nothing defined? I get that this is "Rails magic", but what is the convention that triggers strong params to kick in, and how is it overridden?

Discussion (1)

Collapse
rhymes profile image
rhymes • Edited on

Hi @alton_674 , Rails magic sometimes is indeed too much "magic".

So called "Strong parameters" amount to a mechanism to avoid a technique called mass assignment. Since it's common to do things like:

model.update(params)
Enter fullscreen mode Exit fullscreen mode

by requiring that the developer enumerates which parameters are "safe" for assignment, you can block the client from overriding important data in your model that you didn't intend to change.

Can I ask you more details about the bug you're encountering? You say the controller is throwing an error, which error?

Thank you!