hyper-mesh
hyper-mesh copied to clipboard
Need spec for using the Model.find_by(attribute => value) scope in pre-rendering.
A bug was discovered in staging and production environments only, pre-rendering was breaking with the error RuntimeError (HyperModel fetching records failed, exception caught when applying ["find_by_nickname", "adamcreekroad"] to db object User: method missing):
It is really weird that this was working fine in development...
The fix was pushed in the latest edge branch, but it needs a spec written.
f.when_on_server { @server_data_cache[klass, ["find_by_#{attribute}", value], :id] }
Was changed to:
f.when_on_server { @server_data_cache[klass, ["find_by", { attribute => value }], 'id'] }
There were amazingly two things broken here only in staging and production:
-
find_by_attribute(value)
's secure method was undefined and throwing that original error. -
@value.attributes.has_key?(method)
was returning false when method was:id
, which thatwhen_on_server
call up there passes through.attributes
is a hash of String => String, so checking for a symbol was not working.