Sporadic error in production: NoMethodError: undefined method `input'
I'm getting a sporadic error (full backtrace at https://gist.github.com/4162431) in my newly-deployed Rails 3.2 app in production only. If I refresh the page, the error goes away.
This is happening on all of my pages that render simple forms, and the error only happens occasionally. This also doesn't happen in development environment, so I don't have a clue how to go about debugging it.
@dpmccabe are you running in a threaded environment?
I do encounter errors like that (undefined method `input' for #SimpleForm::FormBuilder:0x000000059fa100) in a multithreaded Rails app. Is simple_form known to be non-threadsafe ?
The issue is that autoload is not threadsafe. There is a SimpleForm.eager_load! method you can call on production on simple form master, to eager load everything, which will definitely help.
Since SimpleForm.eager_load! is in master branch and it should help with this issue I'm closing this. @dpmccabe thanks for letting us know about this issue.
How should I fix this on rails 3.2? There is no eager_load! method on simple_form 2.1, and the latest requires rails 4.
+1 what Papipo said.
2.1 has the same mechanism and should work fine
I tried 2.1 with no luck. I've instead used commit 6ca2a1eb
Included in my Gemfile: gem 'simple_form', git: 'https://github.com/plataformatec/simple_form.git', ref: '6ca2a1eb'
@JonAbrams #723 should fix that on 2.1.0, but you have to enable config.threadsafe! or config. preload_frameworks = true in your application.
Also this commit is included on 2.1.0
Thanks!