Proposal to fix silent marshal failure
pierre-pretorius opened this issue · 3 comments
Hi
It looks like most users workaround the silent marshal failure (#91) by making sure the class you are marshalling is loaded. Example:
require 'post'
class User
include Redis::Objects
list :my_posts, :marshal => true
end
This often causes double load warnings such as: warning: already initialized constant Post::SOME_CONSTANT.
An elegant fix that works with this gem currently is:
class User
include Redis::Objects
list :my_posts, :marshal => Post
end
When the user class is loaded it will cause Rails to autoload the Post model as well so marshalling will work. This gem still evaluates the value passed as truthy so everything keeps working as expected. What is the possibility of making this an actual feature instead of accidental elegant solution?
This is really cool and elegant... does anything need to be done other than just update the README?
We have been using it like that in production for quite some time now so I suspect the answer is no.
Ok thanks, will link to this from the readme.