How to debug in Model?

Viewed 13659

Does anybody know how to debug in rails in the Model? I have a method that is now working and I was trying to check the variable's value in between typing logger.debug val_name that's working in the controllers but not in the models does anyone know why? The model is not inherited from Active Record if it can be the problem. Is there any way to debug it?

4 Answers

Another way to log from anywhere in your application:

Rails.logger.debug "Show this message!"

This will always output to the log/development.log file.

Related