Hi you all,
I have a REST app where I want to consult a resource by all its
different attributes.
So I may have the following URLs:
- List of bugs: /bugs
- The bug with id 1, and so on: /bugs/1
- List of values of "whatever", where "whatever" can be any
of the bug
attributes, such as "state": /bugs/by_whatever
- List of bugs whose attribute "whatever" has the value
"value":
/bugs/by_whatever/value
I have the first two ones urls working (easy). What about the others? I
dunno how to rearrange my routes.rb and what to do with my
BugsController.
- I cannot use nesting resources (nested should have the id of a bug,
like /bugs/{id}/).
- I''ve started adding a new method called "by_state" in my
BugsController, being "state" one of the bug attributes, but an error
appears when accessing url /bugs/by_state: "Couldn''t find Bug with
ID=by_state". Obvious.
- Perhaps a new controller could do the trick. Something like
BugsByController,which would create the /bugs_by/{whatever} URL.
But again, I dunno what to do with the {value} part.
- To solve this I can do one controller for each attribute
BugsByStateController, BugsBy
, but this sounds horrible.
- What about collections? I can have
map.resources :bugs, :collection => { :by_state=> :get, by_dir=> :get,
by_etc... }
Getting URLs such as /bugs/by_state, /bugs/by_dir, etc
But again, what
happens with the "value" part?
Thank you all.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---