Kevin Gorjan
Kevin Gorjan

Reputation: 1332

Rails - explore data from a query

Simple question.

Is there a way to see all your data that your receive from a query in Rails?

Example:

@persons = Person.find(:all)

Is there a way to see all data from @person?

Upvotes: 0

Views: 108

Answers (3)

peter
peter

Reputation: 42207

require 'pp'

pp @persons = Person.find(:all) 

or

puts @persons = Person.find(:all).inspect

Also look at the gem unroller, it's awesome at debugging, look at

http://unroller.rubyforge.org/

for an example with debugging ActiveRecord

Upvotes: 2

p0rter
p0rter

Reputation: 989

open your shell. type in:

rails c

and then

p = Person.find(:all)

and you should see all data. the rails console helped me a lot of times to inspect data.

or

what do you mean with "joined data"? if you just want to see the data you could use a database browser like SQL Database Browser for sqlite

Upvotes: 0

user841092
user841092

Reputation: 156

Try this:

pp @persons

Also you can install this awesome gem: https://github.com/michaeldv/awesome_print and use ap instead. In that case:

ap @persons

Upvotes: 0

Related Questions