Yep, working with AssociationProxy stuff in either the debugger or the
console is nasty. Things have a tendency to happen without being told
to (especially loading the target).

Also, have you tried calling membership.save in your original example?
The code you show will set the FK in membership (via
membership.create_role), but it's not on the DB until you save it...

--Matt Jones

On May 20, 10:34 pm, Brian <[email protected]> wrote:
>
> First, the debugger is giving me something strange in the
> AssociationProxy class in the reload method.  After calling reset (it
> uses AssociationCollection#reset) @loaded == true according to the
> debugger.  If loaded really is true, it might expliain this, but I'm
> still under the assumption that I'm misinterpreting the debugger, or
> the debugger is wrong, because otherwise I misunderstand inheritance
> in ruby and there's a bug in rails (this seems less likely).  I
> haven't been able to duplicate this with a smaller repro, but I'll try
> again tonight.
>
> Second, I think it's very likely that my scenario isn't all that
> common. And it's very likely that the association implementation
> wasn't designed with this in mind.  I'm running into this in a unit
> test.  Instead of creating models in memory, I'll load up data from
> the test DB, and I'm guessing user.roles suddenly starts working.
> Then at least I know I can work around the problem with test fixtures.
>
> In the meantime, if anyone else has an idea of what's going on, let me
> know.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to