I'm using Rails 3.0.0rc and have the following models:

class User
 has_many :readings
 has_many :conversations, :through=>:readings
end

class Reading
 belongs_to :user
 belongs_to :conversation
end

class Conversation
 has_many :readings
 has_many :users, :through=>:readings
end

and this controller code:

class ConversationsController
 def show
 �...@user = User.find(params[:user_id])
 �...@conversation = @user.conversations.find(params[:id])
   debugger
 end
end

After requesting conversations#show, go to debug console and:

User.class.object_id
=> 116350
@conversation.users.first.class.object_id
=> 33660870
@conversation.users.first.instance_of? User
=> true    # Right

Then leave debugging and request the page again:
User.class.object_id
=> 116350
@conversation.users.first.class.object_id
=> 36497930
@conversation.users.first.instance_of? User
=> true    # Right

And then, request the page again:
User.class.object_id
=> 116350
@conversation.users.first.class.object_id
=> 36497930
@conversation.users.first.class.to_s == User.to_s
=> true
@conversation.users.first.instance_of? User
=> false    # Wrong!

This last evaluation is wrong, and breaks equality checks and
expressions such as @conversation.users.include?(some_user)

If I enable class caching, the problem disappears (but that's not
ideal for development). Maybe I'm doing something that breaks
@reflection in association_proxy.rb? Any ideas?
-- 
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-t...@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