I''m on edge rails, WinXP... When I do something like:>> Product.find(:all)I can open my development log file and find the SQL statements that were executed behind the scenes. But I''m lazy and hate switching between my console session and the log file session. Is there any way to interactive ask ActiveRecord what the most reecently-run SQL statement was, so I can stay inside my script\console window? Thanks Jeff -- 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 -~----------~----~----~----~------~----~------~--~---
Jeffrey Hardy
2006-Nov-22 19:01 UTC
Re: Get most recent SQL executed from inside script\console?
One trick I like to do is tail the log in the background, then launch console. $ tail -f log/development.log & $ ./script/console So the log''s contents will still show up on stdout along with whatever you''re doing in the console: >> User.find(:first) User Load (0.000485) SELECT * FROM users LIMIT 1 => #<User:0x23dcf2c...> -- Jeffrey Hardy (packagethief) http://unspace.ca http://beginningrails.com http://quotedprintable.com> I''m on edge rails, WinXP... > > When I do something like: > >>> Product.find(:all) > > I can open my development log file and find the SQL statements that > were > executed behind the scenes. > > But I''m lazy and hate switching between my console session and the log > file session. > > Is there any way to interactive ask ActiveRecord what the most > reecently-run SQL statement was, so I can stay inside my script > \console > window? > > Thanks > Jeff--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeff Cohen
2006-Nov-22 19:29 UTC
Re: Get most recent SQL executed from inside script\console?
Jeffrey Hardy wrote:> One trick I like to do is tail the log in the background, then launch > console. > > $ tail -f log/development.log & > $ ./script/console >Except I''m on Windows. -- 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 -~----------~----~----~----~------~----~------~--~---
Daniel Collis-puro
2006-Nov-22 20:13 UTC
Re: Get most recent SQL executed from inside script\console?
Jeff Cohen wrote:> Except I''m on Windows.I''m sorry. ;-) Have you tried using cygwin? With cygwin, you can have a bash shell on your windows box and a slew of other excellent commands (like grep and tail), too. http://www.cygwin.com/ -DJCP -- 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 -~----------~----~----~----~------~----~------~--~---
Daniel Collis-puro wrote:> Jeff Cohen wrote: >> Except I''m on Windows. > > I''m sorry. ;-)Ha! :-) Yes, many people have had similar sympathies :-)> > Have you tried using cygwin? With cygwin, you can have a bash shell on > your windows box and a slew of other excellent commands (like grep and > tail), too. >True, but I strive for Windows-only solutions as much as I can. Thanks anyway Jeff softiesonrails.com -- 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 -~----------~----~----~----~------~----~------~--~---
Daniel Collis-puro
2006-Nov-22 20:47 UTC
Re: Get most recent SQL executed from inside script\console?
Jeff wrote:> True, but I strive for Windows-only solutions as much as I can. >Admirable. But the DOS shell *sucks*. Think of cygwin as augmenting the capabilities of windows rather than replacing them. You can access your entire windows filesystem through cygwin - I''m not suggesting that you run rails in cygwin. Otherwise, I''d google for "tail for windows" and use that to tail your development log. Hacking ActiveRecord to output log information to two places (it''s already putting it in development.log) seems. . . inelegant. -DJCP -- 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 -~----------~----~----~----~------~----~------~--~---