Some routes are for CRUD operations, such as client, phone_numbers and products. I have 'unique-index' attributes for many of the models. For example, in Client, I could have "email" or "username", whereas in Products I could have "serialnumber", and in PhoneNumber the actual "number" could be unique-index.
So, I have methods in my ApplicationController that receives a JSON in a POST request, with the attribute name and attribute value. The server checks if the value exists and informs the user if the input is valid or if value exists.
So, for these models, I have to declare a route that points to the "unique" method, such as below
routes.rb
resources :clients
resources :phone_numbers
resources :products
post 'clients/unique' => 'clients#unique'
post 'phone_numbers/unique' => 'phone_numbers#unique'
post 'products/unique' => 'products#unique'
My question is: Can I "group" these routes, without prefix (unlike namespace and scope) to just add post 'unique' to them? a pseudo-code would be like this
pseudo-code
group alias: 'modelsWithUniqueAttrs'
resources :clients
resources :phone_numbers
resources :products
add_route 'unique'
end