0

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.

nbkhope
  • 7,360
  • 4
  • 40
  • 58

1 Answers1

1

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.

Joshua Moore
  • 24,706
  • 6
  • 50
  • 73
  • What if you defined the controller using a plural name? Wouldn't that work by default? E.g. ProductsController instead of ProductController – nbkhope Jan 05 '17 at 19:51
  • 1
    That would still be using the default behavior and not changing it to automatically make it plural. So, if you can change the names of your controllers (and/or domains, depending on how you are doing things) then this might work for you. But again, it's not changing the default behavior, like you asked. – Joshua Moore Jan 05 '17 at 19:55