var_dump and die like php, In ruby on rails (debug in ruby on rails) var_dump and die like php, In ruby on rails (debug in ruby on rails) ruby-on-rails ruby-on-rails

var_dump and die like php, In ruby on rails (debug in ruby on rails)


Rails will only output views to the browser. Any other output is sent to STD_OUT on the server.

Debugging from views is simple:

<%= debug @brand %>

But debugging from inside a controller or model requires you to either halt the execution with abort, which will output an error page:

abort @brand.inspect

Or you can write to the rails log with:

logger.debug(@brand.inspect)

You can read the log by using tail -f /logs/development.log from the your shell.


The Rails equivalent of php's var_dump would be debug:

<%= debug @brand_id %>


To display it in the browser you need to add the following code in the view of the action where you are setting the value of @brand_id

<%= @brand_id %>

Hope this helped!