GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
I feel as if this is probably my own fault and I'm just too stupid to notice, but I can't seem to get Strong Parameters to work in production using Unicorn.
The Unicorn workers won't start, failing with uninitialized constant ActiveModel::ForbiddenAttributesProtection (NameError)
I've attached the full log here.
uninitialized constant ActiveModel::ForbiddenAttributesProtection (NameError)
I've got gem 'strong_parameters' in my Gemfile,
and I've got include ActiveModel::ForbiddenAttributesProtection in my model.
Everything works fine locally, and even if I load up the Rails console in Production. It's only when Unicorn tries to spawn that it fails.
Any help would be greatly appreciated.
Did you ever find an answer to this? I'm running into the same problem, though I haven't started trying to solve it yet.
Update: rebooting the server solved the problem. Not sure why such a drastic action was necessary, but hey, whatever works.
have you execute your unicorn using bundle exec?
Yes. (Un)fortunately, this only happened on the first update after adding the strong parameters gem, so I'm not sure if I'd be able to add any more relevant information to this issue.
@Fustrate Unfortunately I didn't find an answer to this, I just stopped using Strong Parameters.
@rafaelfranca Honestly I can't remember.
@rafaelfranca I just hit this issue. I believe it is due to unicorn's restart (kill -s USR2) not updating the Gemfile that is used. I found this related PR that shows the error and a fix: sosedoff/capistrano-unicorn#2. This would also explain @Fustrate's experience of it only happening on restart.
kill -s USR2
In summary, I'm pretty certain it's not a strong_paramaters issue 👍
If you are using rails 4 then remove the strong_parameters initializer (or from your model) and gem 'strong_parameters' from your gemfile. Rails 4 comes with strong parameters enabled by default.