Search code examples
ruby-on-railsruby-on-rails-3puts

Printing an array or object in Ruby on rails. Also view the structure of the data


I'm executing an Active Record query in controller. And now I want to view all of its contents weather it is in the form of array or object. I want to see the structure in which the data is being returned. I'm new to ruby on rails. In PHP we use var_dump() or print_r().


Solution

  • Take a look at this doc, 'Debugging Rails Applications', particularly section 3, 'Debugging with ruby-debug': http://guides.rubyonrails.org/debugging_rails_applications.html