REST own action

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.

Jeff
softiesonrails.com

+1.

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.

Is this URL correct?

.../168.xml;network

or should it actually be

.../168;network.xml

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.

Be careful, semicolon will be deprecated in Rails2.0
http://dev.rubyonrails.org/changeset/6485

Oh thank goodness. Great move! I'm looking forward to the release of
this. I like that idea so much better.

It also removes the confusion between

http://localhost:3000/resource/new

and

http://localhost:3000/resource/:id;edit

If you think about it they are both used to GET the form and not
modify the resource. Yet "new" has a slash and "edit" has a
semicolon.

So I would love to write this instead:

http://localhost:3000/resource/:id/edit

And this will also make custom actions (when they are necessary) feel
more like first class citizens in the URL.

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.

My $0.02,

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}

only http://localhost:3000/users/168.xml;network is correctly
executed...

The change was made in edge rails for Rails 2.0.

also how shoudl I write the URL in my rxml ?, I wrote
:dataURL =>
"http://localhost:3000/users/#{friend.id}.xml;network?from=#{@user.id}&level=#{@level}"

network_user_path(:id => friend, :from => @user, :level => @level)
formatted_network_user_path(:id => friend, :from => @user, :level =>
@level, :format => :xml)