The :memory: is fine. It creates a temporal database in the memory with no file representation. But sharing a query with the model is a bad idea it will come to problems. Better just tell the model the database name and let the model do all the rest. Debug if any of your model methods is called.