Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug in Model?

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?

like image 690
Dennis Avatar asked Aug 15 '10 13:08

Dennis


People also ask

How do I debug AI model?

Debugging steps in the software world Inspect the system thoroughly to find it. Analyze the Error: Analyze the code to identify more issues and estimate the risk that the error creates. Prove the Analysis: Work with automated tests, after analyzing the bug you might find a few more errors in the application.


2 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.

like image 88
Tim Baas Avatar answered Sep 19 '22 09:09

Tim Baas


You can just do "puts" inside of your model method calls and it'll output. You can see it in the rails logs, or the console's output.

like image 40
Jesse Wolgamott Avatar answered Sep 21 '22 09:09

Jesse Wolgamott