A typical Rails route like:
resource :customer
Sets up routes for index, show, etc.
To access all the customers, I can use the route
/customers
To access a single customer, I use:
/customers/1
Whats the most concise, RESTful way to create a route and controller action that would allow a user to view a set of customers, ie something like
/customers/[1,2,3,4,5]
Updated with rationale
The use case:
You could just keep your routes simple: resources :customers
.
The list of ids would be considered as the :id
by the routes, and you would get [1, 2, 3, 4]
in params[:id]
.
Then in your controller, in a before_filter for example, you can check if the id matches a certain regexp (like... /\\[(\\d,)*\\d\\]/
), and if it's the case you can extract the ids.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.