Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 2.00 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Everything works fine when I delete one or more files, I have a problem when no files are deleted and the submit button is pushed and no params is passed.  I get the following error from the chrome debugging tools:
  2.  
  3. POST http://localhost:3000/destroy_multiple?method=Delete 500 (Internal Server Error)
  4.  
  5. here is the text from the console when submitted and error occurs:  
  6.  
  7. Started POST "/destroy_multiple?method=Delete" for 127.0.0.1 at 2011-08-01 17:35:56 -0500
  8.   Processing by PaintingsController#destroy_multiple as JS
  9.   Parameters: {"utf8"=>"✓", "authenticity_token"=>"gGnMbFpv93l15myCPWzFKVf6GprKjJy1ALcThoG7FRA=", "commit"=>"Delete", "method"=>"Delete"}
  10. Rendered paintings/_managefiles_files.html.erb (1.5ms)
  11. Rendered paintings/destroy_multiple.js.erb (2.7ms)
  12. Completed   in 11ms
  13.  
  14. ActionView::Template::Error (You have a nil object when you didn't expect it!
  15. You might have expected an instance of Array.
  16. The error occurred while evaluating nil.empty?):
  17.     26: });
  18.     27: </script>
  19.     28: <%= form_tag({:controller => "paintings", :action => "destroy_multiple", :method => "Delete"}, { :remote => true }) %>
  20.     29:         <% if @folder.empty? %>
  21.     30:                 <div id = "empty">NO Files Uploaded Yet!<br />Click <a href = "/uploadfiles">here</a> to upload files </div>
  22.     31:         <% else %>
  23.     32:         <div id = "foldercontainer">
  24.   app/views/paintings/_managefiles_files.html.erb:29:in `_app_views_paintings__managefiles_files_html_erb__283932883_91149890_11796808'
  25.   app/views/paintings/destroy_multiple.js.erb:1:in `_app_views_paintings_destroy_multiple_js_erb__950045845_91165200_387351126'
  26.  
  27. Rendered /home/rhino/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
  28. Rendered /home/rhino/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4.0ms)
  29. Rendered /home/rhino/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (8.5ms)