How to make Grails 3 use plural routes by default

275 views Asked by At

So I have a Grails (3.2.4) app, but the routes are all set to be singular names by default. For example:

/product/2
/order/4952

I have managed to change the database table naming to use plural using the following in the Product domain class:

static mapping = {
    table "products"
}

Reading the docs, I also found the following (added to UrlMappings.groovy) to create an alias using plural routes:

"/products"(resources:"product")

But the singularly-named routes end up still available. So either /product or /products can be used. Is there a way to change the default Grails routes to always use plural instead of singular naming convention? That is, a way so I don't have to explicitly write code to define them to be plural.

1

There are 1 answers

2
Joshua Moore On

No there is no way to change the default behavior for url mapping in Grails to use plural without you having to explicitly write code to define them.