DEV Community

Robert Sfarzo
Robert Sfarzo

Posted on

Rails debugging

Fear Ye Not the Red Screen of Better Errors

Image description

  • Missing template N -- note controller#action render view's name, and check views for misspelled folder/file names, or missing view
  • No route matches -- compare routes.rb name to controller route name -- check form route exists in routes.rb -- check form route name
  • param is missing or the value is empty: PARAM_NAME -- match the view form element's name to the controller fetch.params name
  • undefined local variable or method NAME -- could be a local view var or method that is missing, but usually missed the @ for an instance variable that is defined in the controller#action
  • uninitialized constant SOMEController -- mispelled/non-matching controller name in routes.rb and the actual filename controllers\NAME_controller.rb
  • class/module name must be CONSTANT for controller -- probably not CamelCase controller name in controller file
  • always check logic, from math calcs to conditionals
  • if a view does not display a value, probably missing the = in <%= %>
  • be sure form text, elements, attributes match perfectly to spec, read more each test failure message and/or the actual test file
  • label && /ROUTE displays NAME entered when the form is submitted errors: match html labels for with the corresponding element id, *these errors cascade to numerous other errors, disappointing at first but a giant relief when corrected

Top comments (0)