Ran into a great problem. REST, as it’s implimented via Rails, identifies the URL as a plural in every case. So you would retrieve a single issue through /issues/. This seems to be technically incorrect.
I find other (non-Rails) documentation talking about this being singular for getting a single issue and plural for a list.
And this is also how the site I’m trying to access is configured. Which means that every time I try to GET a single issue the ActiveResource is calling for /issues/ instead of the correct /issue/.
Does anyone know of a way to workaround this problem using ActiveResource?
Maybe I should ask if anyone else agrees that this is a problem in the implementation of the REST api in ActiveResource?
but I have a lot of associated models to create for this API. Where do I put something like this to override ALL instances of the ActiveResource element_path and collection_path calls?
Ran into a great problem. REST, as it's implimented via Rails,
identifies
the URL as a plural in every case. So you would retrieve a single issue
through /issues/<insert key here>. This seems to be technically
incorrect.
I find other (non-Rails) documentation talking about this being singular
for getting a single issue and plural for a list.
And this is also how the site I'm trying to access is configured. Which
means that every time I try to GET a single issue the ActiveResource is
calling for /issues/<insert key here> instead of the correct
/issue/<insert
key here>.
Does anyone know of a way to workaround this problem using
ActiveResource?
Maybe I should ask if anyone else agrees that this is a problem in the
implementation of the REST api in ActiveResource?
What you express is not a problem. You're confusing parameters and
actual path segments.
The url in rails is indicative of the controller and action at that
point in the site. At its core rails routing looks something like
map.connect ':controller/:action/:id.:format' actions assigned restful
verbs will figure out on their own path, but custom actions will need
their own path segment.
something like mydomain.com/issues means route to the 'issues'
controller with no paramaters, which most commonly will go to the index
action.
something like mydomain.com/issues/4 means route to the 'issues'
controller with parameters {id: 4}. By default mydomain.com/issue/4
would go to a different controller ('issue' which would cause naming
conflicts). You can of course get around this by hardcoding resource
paths.
So from there you can figure out where
/publishers/1/magazines/2/photos/3 goes. Publishers controller, get
action, param id:1, magazines controller, get action,....
This should tell you everything you need to know
Whether or not inflections and pluralizations are a good thing to begin
with, that's a whole nother thread.