It's ok to use the parameters to further "refine" your action, but
just make sure that your custom action shouldn't really be a standard
action of another resource. It could very well be that although your
"network" action seems to be needed on a user resource, perhaps you're
really stumbling upon a discovery of a new resource entirely.
What does the network action try to do? And if you *had* to stick to
the seven RESTful actions, what action would "network" be and for what
resource?
Those are the kinds of questions I ask myself whenever I feel like
adding a custom action, and about half the time, I'm able to just
declare a new resource and remove the custom action.
Actually, everything (authorizations, logins, search, ...) can be fit into
the 7 REST actions. It's just sometimes hard to figure out what sort of resource do you need.
this always confuses me. Should the format extension always appear at
very end of the URL, just before the query string. Before the
semicolon before the custom action?
I think this was one of the reasons we changed it to / in edge rails.
When we actually got to building real restful apps with custom
actions, singleton resources, etc, it was clear using the semicolon
wasn't working out (plus, safari won't send http basic auth with it).
It should be /168/network.xml, which is a lot easier to grasp,
provides a transparent migration to a singleton 'network' resource
should it be necessary, and doesn't mess with caching.
the network action return an xml files where the 'friends' of a user are
described (friends_who_know_me and friends_i_know) one <Person>node
for each friend and one <City> node for each friend.residence... it's a
complete description of a user's network, which is built from user's
relationships
so it's a GET the network of a User....
Why don't you create a resource 'network' which returns your formatted
xml? You could also add routes like 'network/fred/paris'
('network/:person/:location/') to GET from
this resource only the friends of fred located in Paris.
I agree that it's a resource but not in the DB.... it's point I did not
catch very well in RESTFul approach, it seems that all resources ARE
ActiveResources... true or false ?
Resources are only a way to see some data on your network. It's like
models: it could be directly linked to real data in your database or
not. For example, I use an 'auth' resource for my login/logout actions which
maps to cookies.
login POST a cookie, is_logged_in? is a GET on a cookie etc.
could be, but......
no route found to match "/users/168/network.xml" with {:method=>:get}
no route found to match "/users/168;network.xml" with {:method=>:get}