simple_form icon indicating copy to clipboard operation
simple_form copied to clipboard

Sporadic error in production: NoMethodError: undefined method `input'

Open dpmccabe opened this issue 14 years ago • 11 comments

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 avatar Nov 28 '12 16:11 dpmccabe

@dpmccabe are you running in a threaded environment?

rafaelfranca avatar Nov 30 '12 01:11 rafaelfranca

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 ?

isc avatar Jan 11 '13 18:01 isc

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.

josevalim avatar Jan 11 '13 18:01 josevalim

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.

nashby avatar Jan 31 '13 17:01 nashby

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.

Papipo avatar Mar 16 '13 06:03 Papipo

+1 what Papipo said.

JonAbrams avatar Mar 27 '13 17:03 JonAbrams

2.1 has the same mechanism and should work fine

rafaelfranca avatar Mar 27 '13 17:03 rafaelfranca

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 avatar Mar 27 '13 17:03 JonAbrams

@JonAbrams #723 should fix that on 2.1.0, but you have to enable config.threadsafe! or config. preload_frameworks = true in your application.

rafaelfranca avatar Mar 27 '13 18:03 rafaelfranca

Also this commit is included on 2.1.0

rafaelfranca avatar Mar 27 '13 18:03 rafaelfranca

Thanks!

JonAbrams avatar Mar 27 '13 18:03 JonAbrams