Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Singular or plural scope names in Rails

I have a question in my head.

Is there any disadvantage to using singular or plurial in names for scope ? I found nothing on the question. Sometimes I put in the plural to help me understand the real scope without following convention.

There's a convetion?

like image 313
hypee Avatar asked Oct 31 '25 13:10

hypee


1 Answers

I'm not aware of one. I use whatever "reads well." If the scope is filtering there results, then plural seems to read the best -- User.admin vs User.admins. But not all the time. Event.on_date(Time.now) wouldn't make sense as a plural. But then again I'd really rather that was Events.on_date... but I can't do that either.

So for me... whatever reads the best while writing the code is probably the right way to go.

like image 175
Philip Hallstrom Avatar answered Nov 03 '25 05:11

Philip Hallstrom