Closed SyedMSawaid closed 1 year ago
You can't reach into other models unfortunately. You could try making a virtual column on the join table that loads this in as though it was on this table? That's just a guess, I'm not sure if it's possible.
Can RankedModel
help with this or not?
Can you give me an example of how can I create a virtual table on join?
RankedModel is largely the same from memory. I'm not too sure about the virtual column thing but stack overflow has some resources depending on your database system. It requires that your virtual column can reach into another table which may or may not be a thing.
Why not just scope to the todo
itself? Or perhaps 'status' is actually part of the join and can be moved to the join table?
Status can be part of join table. But if I don't have a todo in a sprint? I am not sure how that might work! Any ideas?
I'm afraid that's venturing fairly deep into your specific application design. You might get some help on Stack Overflow though if you ask there.
Haha yes, I saw that. Convoluted but it'll do the job :D Have you tested it out?
Currently, nope. xD It is an answer from StackOverflow so I trust them. If it causes a problem, I'll fix it then. xD
I think it's worth trying, just make sure it can't lead to any SQL injection :)
One more thing, if I change the status of Todo
, it doesn't automatically update the position of it in SprintTodo
. Is there any way to force reset its position?
I don't think that'll easily be possible since all the logic is hanging off the other model and that model isn't even invoked. It's all done using callbacks when creating/updating/deleting the list model. I suppose you could update the Todo
via the SprintTodo
using nested attributes or something like that?
But suppose I change status of Todo
from Todo
table. Is there any way to force reposition its SprintTodo
other than deleting and recreating it?
Not that I'm aware of but feel free to peruse the code. It's not too complicated, just a bit strangely arranged :) All repositioning is handled by callbacks and scope change detection.
Can I do something like this? Or do I have to replicate the status in
SprintTodo
as well?