On 18 August 2011 17:48, Angelo Cordova <acord...@gmail.com> wrote:
>
>> >> > I tried this
>>
>> >> >  def before_create
>> >> >     debugger
>> >> >    stg = Storage.create!(:product_id =>
>> >> > self.product_id, :current_quantity
>> >> >  => self.quantity, :stg_data => purchase.prc_data)
>> >> > end
>>
>> >> > and when I "inspect" the variable "stg" I got  "stg => nil" as result
>>
>> >> That is not surprising since you have broken *before* the line that
>> >> allocates stg.
>>
>> >> Colin
>>
>> > If I break after that line... "stg" does not appear
>>
>> what do you mean it does not appear?
>>
>> Remember that you can inspect data and evaluate expressions in the debugger.
>>
>> Colin
>
> When I used debugger the first time (in the line before the callback)
> I chose option "var local" and I got
>
> stg => nil
>
> But when I use debugger after that line I get this
>
> blk => #<Proc:0xc302b34@/usr/local/ruby/lib/ruby/gems/1.9.1/gems/
> activerecord-3.0.9/lib/active_record/callbacks.rb:277>
>  halted => false
>  key => nil
>  name => nil
>  result => true
>  value => 88
>
>  And if I try to "inspect" stg I get
>
> var instance stg
> NameError Exception: undefined local variable or method `stg' for
> #<DetailPurchase:0xb4d3054>

I have occasionally had problems with the debugger statement at the
end of a method with it apparently dropping out of the method before
breaking, so that variables are no longer accessible.  Add an extra
line after the debugger statement (i=0 for example) to give it
something to break on.

On a separate issue, looking at the message you get, are you using
ruby 1.9.1?  If so then upgrade to 1.9.2 or go back to 1.8.7, ruby
1.9.1 does not work reliably with rails.  This may have nothing to do
with your problem.

I note that you still have not answered my question (unless I missed
it), have you any validations on the Storage model?

Colin

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to