Reputation: 4421
I am using grails 3 to model hierarchical structures in a database to controllers. I have the following URL mapping:
group("/api") {
"/events"(resources: 'event') {
get "/attendees"(controller: 'eventAttendee', action: 'index')
delete "/attendees/$id"(controller:'eventAttendee', action: 'delete')
post "/attendees"(controller:'eventAttendee', action: 'save')
}
"/attendees"(resources: 'attendee')
}
If I GET
/api/events/1/attendees
I see that the params
contain an eventId
field, which correctly displays 1. However, if I DELETE
/api/events/1/attendess/2
I get params where eventId => 2
and Id => 1
(the parameters are swapped). This is causing me some problems, does anyone know how to fix this?
Edit: Regarding the controllers: This is the relevant part of the source, I don't think there's anything suspicious there:
class EventController extends RestfulController {
EventController() {
super(Event)
}
}
class EventAttendeeController {
def delete() {
print "${params.eventId}"
print "${params.Id}"
}
//...
}
Upvotes: 1
Views: 269
Reputation: 61
Although its old question, Trying this might help someone,
group("/api") {
"/events"(resources: 'event') {
"/attendees"(resources: 'attendee')
}
}
Upvotes: 1