Viewing associations in debugger

Hi,

First things first: Just bought your product about a month ago after being a longtime NetBeans user. NetBeans is good, no doubt about it, but I think your IDE is better. Thanks a lot for a great product!

Now to the boring stuff...

I have RubyMine 1.1.1 running on Ubuntu 9.04. Doubt this makes a difference, but you never know. Anyway, the debugger works fine except for one thing, and I don't know if it's me or simply the way the thing works.

Let's say a User has an Account and a Preference. And let's say I have variables defined to hold these entities. When I hit a breakpoint I can see the @attributes (i.e. hash keys and values) if I inspect each variable individually. Let's say I'm inspecting the user. I can see the user's several @attributes, and I can also see that an @account and a @preference exist. (They might be something like <Account:0xc6a5bc4> and  <Preference:0xc56307c>).

The problem comes when I expand @account or @preference. They each have an @attributes member, however, it's always nil, so I can't see what values it has. It would be great if I could examine associations to any level and see what the @attributes are for each one. Can I do that or Is this just the way it's supposed to work?

Thanks,
Larry

4 comments
Comment actions Permalink

Hello Larry,

Excuse me, I didn't understand the use case. Could you attach some screenshots from debugger? And are you able to reproduce this problem in pure ruby example (without rails, etc., just several small classes with similar attributes). I want answer your question but at first I should reproduce the problem on my machine.

0
Comment actions Permalink

Hi Roman,

Thanks for your prompt reply. Here is the info you requested (minus the Ruby-only examples).

My User class:

module Member
  class User < ActiveRecord::Base
              :
    has_one :account, :foreign_key => 'member_user_id'
             :  
  end
end

Simillarly, a Member::Account "belongs_to" a Member::User.

I have attached image files of what's visible in the debugger. Basically, I when I view the User I can see that it has an Account, however I cannot view the attributes for that Account.

Specifically:

Image_1:Shows the debugger stopped after I have created a User. The "Variables" window shows that @user exists and displays its 7 attributes (e.g. first_name, last_name) as a hash. It also shows the existence of an @account as a valid Member::Account object.

Image_2: I have expanded @account and, as you can see, its attributes are 'nil'. It would be nice to see the attributes, such as the login name.

Image_3: Shows that the 'login' for an @account does indeed exist, but the only way I could view it was to actually assign a local variable the value and then view that local variable in the "Variables" window.

Thanks,
Larry



Attachment(s):
Image_3.jpg
Image_2.jpg
Image_1.jpg
0
Comment actions Permalink

Hello Larry,

Ok, I've understand the problem. Probably it it side effect of some rails dynamic magic, I'll try to check it. By the way does "Evaluate Expression" feature work correct for account.login? And does all account's attributes are still 'nil' after your evaluate "account.login" (probably you see some lazy evaluation of fields)?

0
Comment actions Permalink

Hey Roman,

Once again, thanks for your quick reply.

I tried "Evaluate Expression" on a few things and nothing caused it to flush out the values of the other attributes.

By the way, I am doing this in test programs using Cucumber and - more importantly - Factory Girl. I say "more importantly" because I have noticed some truly weird evaluation behavior caused by Factory Girl. I orignally used Machinist but switched to Factory Girl for a couple of reasons. When I did, tests that were working started to fail, all because of association madness.

So... I appreciate your offer to look into this, but I don't think you should (unless you want to). Dynamic magic, as you so accurately call it, can be a real bitch to understand and debug. Throw in a third-party gem that folds in its own third-party dynamic magic and, well... you could be digging for days.

And I don't think it's worth it. I can work around it and you can spend your time on more important things - like enjoying your weekend!

Thanks,
Larry

0

Please sign in to leave a comment.