문제

I have the following nested resources in my rails 3 app.

resources :calendars do
  resources :events
end

What is the recommended url/path for displaying (list or calendar) events for a specific calendar? Should I use the show method of the calendar controller (http://mydomain.com/calendars/1), or the index method of the events controller (http://mydomain.com/calendars/1/events)? Is it a matter of personal preference, or are there conventions/best practices for handling this situation?

Thanks!

도움이 되었습니까?

해결책

The convention in standard RESTful apps would be to use http://mydomain.com/calendars/1/events, since events in your example are a nested resource. That is, the calendar resource has many events resources.

That being said, if you were actually displaying a visual calendar (that happened to have events populated on it), you'd go with http://mydomain.com/calendars/1, since the main resource you're displaying is the actual calendar.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top