Hello. What I''m doing wrong when all my attempts of storing my objects in session ends in 500 error and: --- Session contained objects where the class definition wasn''t available. Remember to require classes for all objects kept in the session. --- in appache.log? When I tried to put built-in types everything is fine. Is the relation, between objects issue? And yes I tried to put require ''my_model''. And also I''m using instance of that class in action. Any help or kick to the right side will be goooooood :-). Please forget me stupidity if there is some. My environment: # uname -a Darwin Zion.local 7.8.0 Darwin Kernel Version 7.8.0: Wed Dec 22 14:26:17 PST 2004; root:xnu/xnu-517.11.1.obj~1/RELEASE_PPC Power Macintosh powerpc # ruby -v ruby 1.8.2 (2004-12-25) [powerpc-darwin7.7.0] # gem list F rails rails (0.9.5) -- pepe
Josef Pospíšil wrote:> Session contained objects where the class definition wasn''t available. > Remember to require classes for all objects kept in the session.When Rails starts processing an HTTP request, all objects stored in a session are loaded by a marshaller from some serialized storage (e.g., a file). The dump basically says to the marshaller "here is an object of class Foo with such and such attributes". For marshaller to make any sense of it, it must know what class Foo is, obviously. So, you need to require every class that you may use in a session somewhere like (IIRC) application.rb Or do yoursef a favor and require everything under app/model in environment.rb, wholesale. If your app does not contan hundreds of model classes, there is no real reason not to do it that way. -- Best regards, Alexey Verkhovsky Ruby Forum: ruby-forum.org (moderator) RForum: rforum.andreas-s.net (co-author) Instiki: instiki.org (maintainer)
Hello. Thanks for session lesson and solution! I thought it would be something like this, but not too deep in rails (yet!:-). I tried to find informations about this for half day, but without luck. -- pepe On 14.2.2005, at 15:52, Alexey Verkhovsky wrote:> Josef Pospíšil wrote: > >> Session contained objects where the class definition wasn''t >> available. Remember to require classes for all objects kept in the >> session. > > When Rails starts processing an HTTP request, all objects stored in a > session are loaded by a marshaller from some serialized storage (e.g., > a file). The dump basically says to the marshaller "here is an object > of class Foo with such and such attributes". For marshaller to make > any sense of it, it must know what class Foo is, obviously. So, you > need to require every class that you may use in a session somewhere > like (IIRC) application.rb > > Or do yoursef a favor and require everything under app/model in > environment.rb, wholesale. If your app does not contan hundreds of > model classes, there is no real reason not to do it that way. > > -- > Best regards, > > Alexey Verkhovsky > > Ruby Forum: ruby-forum.org (moderator) > RForum: rforum.andreas-s.net (co-author) > Instiki: instiki.org (maintainer) > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > lists.rubyonrails.org/mailman/listinfo/rails >