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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With