Hi there, I am a recent convert from PHP, specifically CakePHP. When I would run a query in CakePHP and read that query into an array, I could run a function debug() on that array and it would print all of the contents of that array very neatly on the screen. If I run a query like @order = Order.find(1), it reads all of the order information as well as the related line_items information into the @order variable, but when i run @order.inspect I can only see the order information (and not the associated line_items) and it also reads it out in one long string instead of each hashed value on a new line etc.. Is there a better method than inspect to print the contents of a variable more legibly to the screen? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pardee, Roy
2008-May-20 20:15 UTC
Re: Printing the contents of variables to the screen legibly
Rails also has a debug() function. Not sure if that''d get you child elements automatically tho... -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of validkeys Sent: Tuesday, May 20, 2008 1:08 PM To: Ruby on Rails: Talk Subject: [Rails] Printing the contents of variables to the screen legibly Hi there, I am a recent convert from PHP, specifically CakePHP. When I would run a query in CakePHP and read that query into an array, I could run a function debug() on that array and it would print all of the contents of that array very neatly on the screen. If I run a query like @order Order.find(1), it reads all of the order information as well as the related line_items information into the @order variable, but when i run @order.inspect I can only see the order information (and not the associated line_items) and it also reads it out in one long string instead of each hashed value on a new line etc.. Is there a better method than inspect to print the contents of a variable more legibly to the screen? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-20 21:35 UTC
Re: Printing the contents of variables to the screen legibly
On 20 May 2008, at 21:15, Pardee, Roy wrote:> > Rails also has a debug() function. Not sure if that''d get you child > elements automatically tho...debug is fine in a view, at the console pp (pretty print) is nice too (you need to require ''pp'' first) Fred> > > -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of validkeys > Sent: Tuesday, May 20, 2008 1:08 PM > To: Ruby on Rails: Talk > Subject: [Rails] Printing the contents of variables to the screen > legibly > > > Hi there, > > I am a recent convert from PHP, specifically CakePHP. When I would > run a > query in CakePHP and read that query into an array, I could run a > function debug() on that array and it would print all of the > contents of > that array very neatly on the screen. If I run a query like @order > Order.find(1), it reads all of the order information as well as the > related line_items information into the @order variable, but when i > run > @order.inspect I can only see the order information (and not the > associated line_items) and it also reads it out in one long string > instead of each hashed value on a new line etc.. Is there a better > method than inspect to print the contents of a variable more legibly > to > the screen? > > Thanks! > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Daniel Waite
2008-May-20 21:38 UTC
Re: Printing the contents of variables to the screen legibly
validkeys wrote: Is there a better> method than inspect to print the contents of a variable more legibly > to the screen?If I''m in a view I use Rails'' debug method. Everywhere else (including the logger) I use object.to_yaml. Works beautifully. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
validkeys
2008-May-20 22:02 UTC
Re: Printing the contents of variables to the screen legibly
is there anyway to see the related information as well? Like a query that returns a post and all related comments. Debug only seems to show the post but not the comments. On May 20, 5:38 pm, Daniel Waite <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> validkeys wrote: > > Is there a better > > > method than inspect to print the contents of a variable more legibly > > to the screen? > > If I''m in a view I use Rails'' debug method. Everywhere else (including > the logger) I use object.to_yaml. > > Works beautifully. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Daniel Waite
2008-May-20 22:32 UTC
Re: Printing the contents of variables to the screen legibly
validkeys wrote:> is there anyway to see the related information as well? Like a query > that returns a post and all related comments. Debug only seems to show > the post but not the comments. > > On May 20, 5:38 pm, Daniel Waite <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>It will show whatever is held in memory when dumped. If you have a post with comments try... post.comments debug post And it should spit out everything. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---