更新时间:2023-11-24 09:35:22
由于新的rails生成后,由于rails4("@ emil-kampp"提到了此参数)中的强参数",您可能会在日志中得到Unpermitted parameters:
.它们是在您的控制器中生成的.因此,使用您的代码看起来像:
You're probably getting an Unpermitted parameters:
in your log due to Strong Parameters in rails4 (@emil-kampp mentioned this), after a fresh rails generate, they are generated in your controller. So using your code it would look something like:
class EmployersController < ApplicationController
# <snip>
def update
@employer.update(employer_params)
end
def employer_params
params.require(:employer).permit(:name, { :employer_ids => [] })
end
end
也请参见问题可以回答这个问题.希望这可以节省一些人的时间.
Also see this Question on SO which answers this. Hopefully this saves someone a few cycles.