It sounds like you might want to create a wrapper class for these objects that inherits from ActiveRecord::Base.
The attributes on your wrapper object would be whatever information is required to instantiate the object via the gem. Then you would create (or override) a finder method that does so.
class FooWrapper < ActiveRecord::Base
attr_accessible :x, :y, :z
def self.get_real_foo(wrapper_id)
wrapper_obj = self.find(wrapper_id)
return FooGem.new(wrapper_obj.x, wrapper_obj.y, wrapper_obj.z)
end
end
You say you tried storing the object in the session and your models? How exactly did you go about that? This may not really be the best way to solve your problem... If you post more specifics we will be better able to help you down the right path.
Edit Addition:
If you want the gem instance to be tied to a specific user then make FooWrapper :belongs_to :user
. When you instantiate the real gem instance then you use whatever user-specific information as needed.