John Merlino
2011-May-05 01:39 UTC
Given I know where a method is defined, I want to know where its called (at runtime)
Hey all, application completely breaks down in production mode. I followed the execution file by file line by line and yet I cannot figure out where an instance variable is being generated from. But I have a suspicion. This method right here: # neeeded becasuse of a rails bug def to_s "#{self.class.name.underscore}__#{object_id}" end I think it''s cause of problem. I also noticed that the developer left a comment above it. Problem is it''s part of a class that gets yielded into a ruby block and there''s a number of partials that get rendered in the new view. But I cannot find for the life of me where to_s is called during execution of clicking a new button. I need some debugging advice for this. Thanks for response. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2011-May-05 01:48 UTC
Re: Given I know where a method is defined, I want to know where its called (at runtime)
On May 4, 2011, at 6:39 PM, John Merlino wrote:> Hey all, application completely breaks down in production mode. I > followed the execution file by file line by line and yet I cannot figure > out where an instance variable is being generated from. But I have a > suspicion. This method right here: > > # neeeded becasuse of a rails bug > def to_s > "#{self.class.name.underscore}__#{object_id}" > end > > I think it''s cause of problem. I also noticed that the developer left a > comment above it. Problem is it''s part of a class that gets yielded into > a ruby block and there''s a number of partials that get rendered in the > new view. But I cannot find for the life of me where to_s is called > during execution of clicking a new button. > > I need some debugging advice for this.caller() should help... http://www.ruby-doc.org/core/classes/Kernel.html#M001397 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
John Merlino
2011-May-05 02:04 UTC
Re: Given I know where a method is defined, I want to know where its called (at runtime)
Philip Hallstrom wrote in post #996721:> On May 4, 2011, at 6:39 PM, John Merlino wrote: > >> I think it''s cause of problem. I also noticed that the developer left a >> comment above it. Problem is it''s part of a class that gets yielded into >> a ruby block and there''s a number of partials that get rendered in the >> new view. But I cannot find for the life of me where to_s is called >> during execution of clicking a new button. >> >> I need some debugging advice for this. > > > caller() should help... > > http://www.ruby-doc.org/core/classes/Kernel.html#M001397It appears caller expects an argument. This is not a setter method. There is no argument passed to this object, and in your example, if i add one like ''skip'', of course I receive an exception "wrong number of arguments". -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-May-05 07:22 UTC
Re: Re: Given I know where a method is defined, I want to know where its called (at runtime)
On 5 May 2011, at 03:04, John Merlino <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Philip Hallstrom wrote in post #996721: >> On May 4, 2011, at 6:39 PM, John Merlino wrote: >> >>> I think it''s cause of problem. I also noticed that the developer left a >>> comment above it. Problem is it''s part of a class that gets yielded into >>> a ruby block and there''s a number of partials that get rendered in the >>> new view. But I cannot find for the life of me where to_s is called >>> during execution of clicking a new button. >>> >>> I need some debugging advice for this. >> >> >> caller() should help... >> >> http://www.ruby-doc.org/core/classes/Kernel.html#M001397 > > It appears caller expects an argument. This is not a setter method. > There is no argument passed to this object, and in your example, if i > add one like ''skip'', of course I receive an exception "wrong number of > arguments". >The argument to caller is optional. You might also want to install ruby-debug and add a breakpoint. Fred> -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-May-05 08:27 UTC
Re: Given I know where a method is defined, I want to know where its called (at runtime)
On 5 May 2011 02:39, John Merlino <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hey all, application completely breaks down in production mode. I > followed the execution file by file line by line and yet I cannot figure > out where an instance variable is being generated from. But I have a > suspicion. This method right here: > > # neeeded becasuse of a rails bug > def to_s > "#{self.class.name.underscore}__#{object_id}" > end > > I think it''s cause of problem. I also noticed that the developer left a > comment above it. Problem is it''s part of a class that gets yielded into > a ruby block and there''s a number of partials that get rendered in the > new view. But I cannot find for the life of me where to_s is called > during execution of clicking a new button. > > I need some debugging advice for this.If all else fails put some code there that generates a runtime error, then you will get a stack trace. If you only want it to stop under some conditions use a global variable and test it at the offending point to find out whether to crash or not. Fred''s suggestion of using ruby-debug and putting a (possibly conditional) breakpoint there is probably better. Colin> > Thanks for response. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
John Merlino
2011-May-06 00:54 UTC
Re: Re: Given I know where a method is defined, I want to know where its called (at runtime)
> The argument to caller is optional. You might also want to install > ruby-debug and add a breakpoint. > > FredYeah kind of like breakpoint in C++. Thanks for response. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.