tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

Are there any plans to support ActiveRecord `.find_by_xxx`?

Open pvcresin opened this issue 10 months ago • 2 comments

If I understand correctly, I think it is currently as follows

# NG
Article.find_by_id(target_id) # -> error: find_by_id not found

# OK
Article.find_by(id: target_id) # -> no error

I would like Tapioca to support the generation of .find_by_xxx.

Do you have plans to do so?

pvcresin avatar Feb 20 '25 08:02 pvcresin

I think they are implemented here. We know the attribute names so we could do it in ActiveModelAttributes compiler. But I don't know why they aren't defined together with the attributes themselves, maybe there's a potential blocker there, cc @paracycle.

KaanOzkan avatar Feb 21 '25 15:02 KaanOzkan

@KaanOzkan Thank you for sharing the details. I guessed that generating the type for the .find_by_x method would affect the performance of the type checking because of the large size of the RBI definition.

pvcresin avatar Feb 24 '25 14:02 pvcresin