This is a weird one.  It would be one thing if is_a? failed consistently
but if I refresh the page the second attempt always works.

I have the following code that works fine every time:

@node = Node.find(params[:id])
@node.is_a?(Node) # => always will return true

However I recently added an accounts layer to my code and now the query
looks like this:

class Account
  has_many :nodes
end

@node = current_account.nodes.find(params[:id])
@node.class       # => Node
@node.is_a?(Node) # => false on first request, true on subsequent ones


The sql query generated from the above query looks fine:
SELECT "nodes".* FROM "nodes" WHERE ("nodes".account_id = 1) AND
("nodes"."id" = 42) LIMIT 1


But something funny is going on because not even the following works:
@node = current_account.nodes.find(params[:id])
@node               # => #<Node:0x00000104cea108>
@node.class         # => Node
@node.class == Node # => false


I appreciate any input.  Been banging my head on this one for a while
now and making no progress.

-- 
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 [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