my develop environment:
windows xp
F:\>ruby -v
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
F:\>rails -v
Rails 3.0.5
在session中存了一个对象,并将session存到数据库中时,报错:undefined class/module Function
解决方法:在application_controller中加入
before_filter :preload_models
def preload_models()
Model1
Model2
...
...
...
Model9
end
参考:http://www.philsergi.com/2007/06/rails-memcached-undefinded-classmodule.html
http://shiningray.cn/rails-memcached-undefined-classmodule.html
本文介绍了一个在Rails应用中使用session存储对象时遇到的undefined class/module Function错误及其解决方案。通过在application_controller中定义preload_models before_filter,预先加载所有可能用到的模型,避免了将未加载的模型序列化到session中导致的问题。
214

被折叠的 条评论
为什么被折叠?



