I am new, coming from a PHP background. In PHP , you can use var_dump(var) and you will be presented with all of a variables info. Is there a way to dump in RoR? For instance, can I dump my :customers object from my controller or something? 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 -~----------~----~----~----~------~----~------~--~---
On 29 Aug 2008, at 20:37, trope <jtropeano-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am new, coming from a PHP background. > > In PHP , you can use var_dump(var) and you will be presented with all > of a variables info. > > Is there a way to dump in RoR? For instance, can I dump my :customers > object from my controller or something? >There''s the debut view helper that pretty much does that Fred> 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 -~----------~----~----~----~------~----~------~--~---
On 29 Aug 2008, at 22:15, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 29 Aug 2008, at 20:37, trope <jtropeano-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> I am new, coming from a PHP background. >> >> In PHP , you can use var_dump(var) and you will be presented with all >> of a variables info. >> >> Is there a way to dump in RoR? For instance, can I dump my :customers >> object from my controller or something? >> > There''s the debut view helper that pretty much does that >That should of course be the debug helper> Fred >> 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 -~----------~----~----~----~------~----~------~--~---
# in controller logger.debug { @variable.inspect } # in view <%= debug(@variable) %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
trope wrote:> I am new, coming from a PHP background. > > In PHP , you can use var_dump(var) and you will be presented with all > of a variables info. > > Is there a way to dump in RoR? For instance, can I dump my :customers > object from my controller or something? > > Thanks!i did this.. and its working ok for me so far: def myaction render :text myvar.inspect end im also from a php background and am used to being able to do anything i want anywhere in the app.. in rails its a bit weird to have to .. hack out variable dumping.. but anyway i hope that helps.. -- Posted via http://www.ruby-forum.com/.
Alex Pilon wrote:> def myaction > render :text myvar.inspect > end > > im also from a php background and am used to being able to do anything i > want anywhere in the app.. in rails its a bit weird to have to .. hack > out variable dumping.. but anyway i hope that helps..def myaction raise myvar.inspect end that trick is in the book. However, you should have many unit tests ("functional" tests) for each of your actions, so you should be able to just do this: def myaction pp myvar end then run all the tests. -- Phlip http://flea.sourceforge.net/resume.html
In a view you can do this: <%= debug @some_var %> In a controller or model you can do this: logger.info @some_var.inspect -- Benjamin Curtis http://railskits.com/ - Ready-made Rails code http://catchthebest.com/ - Team-powered recruiting http://www.bencurtis.com/ - Personal blog On Mon, May 18, 2009 at 9:34 PM, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Alex Pilon wrote: > > > def myaction > > render :text myvar.inspect > > end > > > > im also from a php background and am used to being able to do anything i > > want anywhere in the app.. in rails its a bit weird to have to .. hack > > out variable dumping.. but anyway i hope that helps.. > > def myaction > raise myvar.inspect > end > > that trick is in the book. However, you should have many unit tests > ("functional" tests) for each of your actions, so you should be able to > just do > this: > > def myaction > pp myvar > end > > then run all the tests. > > -- > Phlip > http://flea.sourceforge.net/resume.html > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Another alternative, where appropriate, is to use the ruby debugger and break at the appropriate point to display the object using the debugger command line. Colin 2009/5/19 Benjamin Curtis <benjamin.curtis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> In a view you can do this: > <%= debug @some_var %> > > In a controller or model you can do this: > > logger.info @some_var.inspect > > -- > Benjamin Curtis > http://railskits.com/ - Ready-made Rails code > http://catchthebest.com/ - Team-powered recruiting > http://www.bencurtis.com/ - Personal blog > > > > > On Mon, May 18, 2009 at 9:34 PM, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> Alex Pilon wrote: >> >> > def myaction >> > render :text myvar.inspect >> > end >> > >> > im also from a php background and am used to being able to do anything i >> > want anywhere in the app.. in rails its a bit weird to have to .. hack >> > out variable dumping.. but anyway i hope that helps.. >> >> def myaction >> raise myvar.inspect >> end >> >> that trick is in the book. However, you should have many unit tests >> ("functional" tests) for each of your actions, so you should be able to >> just do >> this: >> >> def myaction >> pp myvar >> end >> >> then run all the tests. >> >> -- >> Phlip >> http://flea.sourceforge.net/resume.html >> >> >> >> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Finally, when using mongrel, you can always print to the console: print @variable.inspect Cheers, Sazima On May 19, 4:08 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Another alternative, where appropriate, is to use the ruby debugger and > break at the appropriate point to display the object using the debugger > command line. > Colin > > 2009/5/19 Benjamin Curtis <benjamin.cur...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > In a view you can do this: > > <%= debug @some_var %> > > > In a controller or model you can do this: > > > logger.info @some_var.inspect > > > -- > > Benjamin Curtis > >http://railskits.com/- Ready-made Rails code > >http://catchthebest.com/- Team-powered recruiting > >http://www.bencurtis.com/- Personal blog > > > On Mon, May 18, 2009 at 9:34 PM, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> Alex Pilon wrote: > > >> > def myaction > >> > render :text myvar.inspect > >> > end > > >> > im also from a php background and am used to being able to do anything i > >> > want anywhere in the app.. in rails its a bit weird to have to .. hack > >> > out variable dumping.. but anyway i hope that helps.. > > >> def myaction > >> raise myvar.inspect > >> end > > >> that trick is in the book. However, you should have many unit tests > >> ("functional" tests) for each of your actions, so you should be able to > >> just do > >> this: > > >> def myaction > >> pp myvar > >> end > > >> then run all the tests. > > >> -- > >> Phlip > >> http://flea.sourceforge.net/resume.html