Ruby on Rails: Erreur de serveur avec tout en essayant de télécharger un fichier en utilisant attachment_fu: (ne peut pas convertir en entier nul)
-
26-10-2019 - |
Question
J'ai suivi un exemple simple pour télécharger un fichier (voir le lien vers le code ci-dessous). Quand j'ajouter au formulaire de téléchargement le champ <% = f.file_field: uploaded_data%>, puis cliquez sur le bouton d'envoi du formulaire (avec ou sans pièce jointe), je reçois un message d'erreur dans la page web: 500 Internal Server Error
Sur le serveur journal je reçois un message d'erreur: TypeError (ne peut pas convertir en entier nul):
Je suis sur des rails 3.0.5, Ruby 1.9.2, Windows 7
I utilisé l'exemple de code à l'adresse: http: //clarkware.com/blog/2007/02/24/file-upload-fu
Ci-dessous vous trouverez une version imprimée du journal du serveur:
Rendered mugshot/new.html.erb within layouts/application (10.0ms)
Completed 200 OK in 289ms (Views: 49.0ms | ActiveRecord: 0.0ms)
Error during failsafe response: ActionView::Template::Error
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:in `method_missing'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/http/parameters.rb:10:in `parameters'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb:3:in `_c___uby____
lib_ruby_gems_______gems_actionpack_______lib_action_dispatch_middleware_templates_rescues_diagnostics_erb___637362275_26463528_704965928'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_view/template.rb:135:in `block in render'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:54:in `instrument'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_view/template.rb:127:in `render'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_view/render/rendering.rb:59:in `block in _render_template'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `block in instrument'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/notifications.rb:52:in `instrument'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_view/render/rendering.rb:56:in `_render_template'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_view/render/rendering.rb:26:in `render'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/show_exceptions.rb:88:in `rescue_action_locally'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/show_exceptions.rb:68:in `render_exception'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/show_exceptions.rb:59:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/rack/logger.rb:13:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/runtime.rb:17:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/lock.rb:11:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/middleware/static.rb:30:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/application.rb:168:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/rack/log_tailer.rb:14:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/content_length.rb:13:in `call'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/handler/webrick.rb:52:in `service'
c:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
c:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
c:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
"POST Commencé / Mugshots" pour 127.0.0.1 à 2011-03-16 23:12:29 -0700
TypeError (ne peut pas convertir en entier nul):
La solution
Ce tutoriel est très ancienne et probablement pas pertinente pour Rails 3.x. Je ne suis même pas sûr attachment_fu fonctionne avec la version actuelle de Rails.
Je recommande ou paperclip carrierwave
Autres conseils
Il y a quelques changements avec attachment_fu mais il est disponible en rails3.Still si vous voulez peut aller pour paperclip. attachment_fu
J'ai également fait face à ce problème. Le problème est à cause de gemme attachment_fu ou plug-in. Il suffit de le désinstaller et utiliser tout autre plug-in ou gem va résoudre votre problème.