Would like to display some debug code, the file being executed. I want to see something like "File: app/views/site/file.rhtml" Have tried displaying __FILE__ and get a consistent string, regardless of the page displayed. That is "script/../config/../app/views/layouts/application.rhtml" Have tried $0 which displays a consistent string, "script/server". Is there another variable, or another technique, to display the file names I desire? e.g. /app/views/<dir>/<file> I''m new to ROR. Thank go to the Rails Space book! Many thanks! -- 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 -~----------~----~----~----~------~----~------~--~---
Drub Drub wrote:> > Would like to display some debug code, the file being executed. > > I want to see something like "File: app/views/site/file.rhtml" > > Have tried displaying __FILE__ and get a consistent string, regardless > of the page displayed. That is > "script/../config/../app/views/layouts/application.rhtml" > > Have tried $0 which displays a consistent string, "script/server". > > Is there another variable, or another technique, to display the file > names I desire? e.g. /app/views/<dir>/<file> > > I''m new to ROR. Thank go to the Rails Space book! > > Many thanks!I am not sure if this will do it, but off the top of my head I would say have a look in the params hash. Everytime an action is called, I think the controller and action are pushed into the params hash. This only works assuming that you are rendering a template for each action and the template has the same name as the action (you would have had to have overridden that behaviour). Try accessing params[:controller] and params[:action]. If that works, then the file will be found at /app/views/params[:controller]/params[:action] (Extensions will not be included) -- 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 -~----------~----~----~----~------~----~------~--~---
Many thanks, ce bi. Ya got me thinking in the right direction. Bravo. I found that <%= debug(params) %> works quite nicely. You''re right, params contains both the the action and the controller. This line displays both. Just what was needed. Now, on to the next stumbling stone. ;-) Feel like I''m trying to drink from a fire hose! Drub ce bi wrote:> Drub Drub wrote: >> >> Would like to display some debug code, the file being executed. >> >> I want to see something like "File: app/views/site/file.rhtml" >> >> Have tried displaying __FILE__ and get a consistent string, regardless >> of the page displayed. That is >> "script/../config/../app/views/layouts/application.rhtml" >> >> Have tried $0 which displays a consistent string, "script/server". >> >> Is there another variable, or another technique, to display the file >> names I desire? e.g. /app/views/<dir>/<file> >> >> I''m new to ROR. Thank go to the Rails Space book! >> >> Many thanks! > > I am not sure if this will do it, but off the top of my head I would say > have a look in the params hash. Everytime an action is called, I think > the controller and action are pushed into the params hash. > > This only works assuming that you are rendering a template for each > action and the template has the same name as the action (you would have > had to have overridden that behaviour). > > Try accessing params[:controller] and params[:action]. If that works, > then the file will be found at > /app/views/params[:controller]/params[:action] > > (Extensions will not be included)-- 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 -~----------~----~----~----~------~----~------~--~---
The other thing to check out, if you''re just looking to debug, is the log ( log/<environment>.log ). I tail it as I am developing and debugging my site. It will print the params hash for every request, as well as the SQL that is executed, benchmarks and what exactly is being rendered. If you would like to log your own info to that log, call logger.info <message> from within a controller, model or view and have a look in the log. Very useful for debugging. Good luck with the firehose. Drub Drub wrote:> Many thanks, ce bi. Ya got me thinking in the right direction. Bravo. > > I found that > > <%= debug(params) %> > > works quite nicely. You''re right, params contains both the the action > and the controller. This line displays both. > > Just what was needed. > Now, on to the next stumbling stone. ;-) > Feel like I''m trying to drink from a fire hose! > > Drub > > ce bi wrote: >> Drub Drub wrote: >>> >>> Would like to display some debug code, the file being executed. >>> >>> I want to see something like "File: app/views/site/file.rhtml" >>> >>> Have tried displaying __FILE__ and get a consistent string, regardless >>> of the page displayed. That is >>> "script/../config/../app/views/layouts/application.rhtml" >>> >>> Have tried $0 which displays a consistent string, "script/server". >>> >>> Is there another variable, or another technique, to display the file >>> names I desire? e.g. /app/views/<dir>/<file> >>> >>> I''m new to ROR. Thank go to the Rails Space book! >>> >>> Many thanks! >> >> I am not sure if this will do it, but off the top of my head I would say >> have a look in the params hash. Everytime an action is called, I think >> the controller and action are pushed into the params hash. >> >> This only works assuming that you are rendering a template for each >> action and the template has the same name as the action (you would have >> had to have overridden that behaviour). >> >> Try accessing params[:controller] and params[:action]. If that works, >> then the file will be found at >> /app/views/params[:controller]/params[:action] >> >> (Extensions will not be included)-- 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 -~----------~----~----~----~------~----~------~--~---