Show the plural name for a model in the model editor

I understand it is a legacy decision that Dato models must be singular, and then referenced as plural.

However, I don’t want to have to guess what the plural version will be. Please can the model editor show me both the single and plural form of the model name?

Currently it only reminds me of the singular.

image

I have to guess that Dato knows “person” becomes “people”. My first attempt would be to assume that Dato isn’t smart, and would call it “persons”.

the only robust way to deal with that is to add _model in the API key.

I know this is not nice, but we cannot change that now, sorry!

Can you please go into a bit of detail about how it converts a singular noun to a plural? Does it just prohibit singular names ending in “s” and then add that “s” back into the plural name?

What happens to model names that always have an s, even for the singular, like “species” or “glasses” or “electronics”?

Sure @roger we use the Rails inflector, with all its bugs: pluralize (String) - APIdock

Is this what you were expecting?

Perfect, thanks @mat_jack1!

I was just curious. Other systems allow you to manually specify the manual & plural versions, but it’s not a big deal either way as long as I know how it works and how to find the plural name.

Thanks for the details.

1 Like

Hi @mat_jack1 , can you expand a bit further here? Working with the auto pluralisation is proving a nightmare. For instance if a model is named “home”, Dato will not pluralise this. Where can I discover this logic? It creates a disconnect between the api_key and the methods to access models, and I am left trying to guess the right method name.

hello @convincible unfortunately the initial choice of using Rails inflector has been proved unfortunate. The thing you can do to avoid that is to append _model and _field to your models and fields API keys, so that you get a regular singular/plural value.

Otherwise you can check the irregularities here: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/inflections.rb but I think this doesn’t scale well :frowning:

Let me know if you need more info!