Skip to content

Instantly share code, notes, and snippets.

@dohoonk
Last active March 9, 2016 00:19
Show Gist options
  • Select an option

  • Save dohoonk/402d7fe76192ded30070 to your computer and use it in GitHub Desktop.

Select an option

Save dohoonk/402d7fe76192ded30070 to your computer and use it in GitHub Desktop.
Debugging

#Steps to debug 1.Read the error message multiple times Where do I find the message? Read and Read and Read

2.Google the error message copy and paste to google the error msg

3.User tools Railslogger Rails.logger.info ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #{user}" user.inspect might give you nicer log keep in mind that there are different log levels if you are in development all the messages will show if you are in production it will show limited messages

if you are testing things in the view files <%= debug %> ex. <%= debug current_user %> this will display logs in your browers

byebug useful as it will stop the code at the point in your rails log you can see where the code has stopped and interact by calling instance variables if you type n it will take you to the next line c will continue and finish the request for you

Chrome Developer Tools (javascript)

Ask! Try on the problem 30 mins but if you feel like you are stuck, ask!

Things to keep in mind

Test as early as possible!

Make a note of error messages

Try things differently

Re-Build Feature if you are using git worst case scenario

Restart the computer ps aus | grep spring shows you all the spring process that are running at the moment

Check out pry-rails show-routes show-models you can lixus commands in the command console .ls .pwd enter different modes ex.cd Question instead of Question.all you can type all ls -m will list out all the method show-method category_name will grab that method and print it out for you binding.pry

atom ~/pry.rc

  begin
  require 'hirb'
rescue LoadError
  # Missing goodies, bummer
end

if defined? Hirb
  # Slightly dirty hack to fully support in-session Hirb.disable/enable toggling
  Hirb::View.instance_eval do
    def enable_output_method
      @output_method = true
      @old_print = Pry.config.print
      Pry.config.print = proc do |*args|
        Hirb::View.view_or_page_output(args[1]) || @old_print.call(*args)
      end
    end
    
    def disable_output_method
      Pry.config.print = @old_print
      @output_method = nil
    end
  end
  
  Hirb.enable
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment