You can debug Rails

Blog ยป You can debug Rails

Posted on 15 Dec 2010 02:03

Insert

debugger

to invoke the full debuger.

Insert

puts "DEBUG MyObject: #{my_object.to_yaml}"

to display your objects while your code is working.

Insert

caller do |frame| puts frame end

to print stack trace

And you can use

class AClass
   def method_added( method_name )
        puts "DEBUG: 
        caller do |frame| puts frame end
   end
end

to find out who is modifying a class (Because a class can be modified by more than one party).

And instead of all that puts you can use Rails::logger.debug in Rails.

Finally keep reading Programming Ruby

If you like this page, please spread the word: diggdel.icio.usFacebook

You can contact me if you have questions or corrections.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License