guest
August 22, 2006, 6:19pm
1
I know DHH said anything can fit into the seven actions if you think
about it enough but, my current delimma has me thinking otherwise.
So I’m doing an internal messaging system. The user will have an inbox,
sent, deleted etc. To show these I need to query the data in different
ways.
Messages.find(:all, :conditions => ["to_user_id = ?, @me ] for inbox, and
so on.
Any thoughts on how I can make this RESTful? More models perhaps?
filters?
Thanks.
guest
August 22, 2006, 6:58pm
2
On Aug 22, 2006, at 12:19 PM, Guest wrote:
filters?
I would have thought your example was a perfectly RESTful thing to
do, probably in your messages controller.
Providing your user authentication complies with HTTP standards, then
scoping your queries isn’t necessarily un-RESTful.
James.
–
James S. : Freelance Web D.
Work : http://jystewart.net
Play : http://james.anthropiccollective.org
guest
August 22, 2006, 7:28pm
3
So you’re saying call a before_filter on the index action or something?
James S. wrote:
On Aug 22, 2006, at 12:19 PM, Guest wrote:
filters?
I would have thought your example was a perfectly RESTful thing to
do, probably in your messages controller.
Providing your user authentication complies with HTTP standards, then
scoping your queries isn’t necessarily un-RESTful.
James.
–
James S. : Freelance Web D.
Work : http://jystewart.net
Play : http://james.anthropiccollective.org
guest
August 22, 2006, 9:07pm
4
I’m acutally using that plugin. It’s great!
I’m not really having trouble with that though. I’m wondering how I
should do the search for either sent, received, or deleted messages,
based on who’s logged in, in a RESTful manner.
Without the REST stuff, I would have probably had three separate
actions:
get_sent_messages
get_received_messages
get_deleted_messages
That doesn’t fit into the whole REST seven actions thing though. I want
to show three different views of the data, sent, received or deleted.
Thanks James.
James S. wrote:
For the authentication, yes.
I see that a RESTful authentication plugin was just released (haven’t
had a chance to try it yet):
http://www.agilewebdevelopment.com/plugins/restful_authentication
James.
On Aug 22, 2006, at 1:28 PM, Guest wrote:
scoping your queries isn’t necessarily un-RESTful.
James.
–
James S. : Freelance Web D.
Work : http://jystewart.net
Play : http://james.anthropiccollective.org
guest
August 22, 2006, 8:37pm
5
For the authentication, yes.
I see that a RESTful authentication plugin was just released (haven’t
had a chance to try it yet):
http://www.agilewebdevelopment.com/plugins/restful_authentication
James.
On Aug 22, 2006, at 1:28 PM, Guest wrote:
scoping your queries isn’t necessarily un-RESTful.
James.
–
James S. : Freelance Web D.
Work : http://jystewart.net
Play : http://james.anthropiccollective.org
guest
August 23, 2006, 3:19pm
6
On Aug 22, 2006, at 3:07 PM, Guest wrote:
get_received_messages
get_deleted_messages
That doesn’t fit into the whole REST seven actions thing though. I
want to show three different views of the data, sent, received or
deleted.
That depends whether you’d consider the different status messages as
distinctly different resources, or whether those methods are simply
different conditions.
If they’re different kinds of resources, you should probably use
separate controllers for each. If it’s options for what to display,
you could consider using a query string:
/messages/?status=sent
or you could add extra methods, so long as they map to methods
map.resources :messages, :collection => { :sent => :get, :received
=> :get, :deleted => :get }
which I believe would give you:
/messages/;sent
/messages/;received
/messages/;deleted
James.