Spine.find
only looks in the already loaded records. Doing an ajax request isn't the function of find
. So you have to try-catch your find and when it gives this error, you have to fetch it.
id = 1152
try
product = Product.find id
catch err
Product.fetch(
data:
id: id
processData: true
)
# Try again after Product.refresh
To be honest, I think this isn't a nice way to do it, but it is how spine works... I rather have it fetch it automatically, or at least not throwing an error on find.