Thriving K. wrote:
> In this case i want to get method name in view for example
> 
> http://localhost:3000/todo/all_project_todos/14
>   - method name is "all_project_todos"
> 
> http://localhost:3000/todo/completed_todos/14
>   - method name is "completed_todos"

I can't put my finger on it right now, but this approach feels wrong to 
me. Maybe it has something to do with my embrace of RESTful style 
applications, but those URLs look redundant to me. The are both 
referencing a "Todo" resource identified by 14. It shouldn't matter 
whether it's completed or not in this context.

As for the "all" and "completed" collection of "todos," that could be 
handled using named_scope. It just feels to me that the decision of what 
to included in the collection is happing in the wrong place.

I would foresee URLs that look more like this:

Todo #14:
GET: http://example.com/todos/14

All project todos:
GET: http://example.com/projects/1/todos

Completed project todos:
GET: http://example.com/projects/1/todos?completed=true

All completed todos:
GET: http://example.com/todos?completed=true

This approach eliminates the need you're requesting. And, this is also 
likely why you were having trouble finding answers to your question 
through Google. All I'm saying is to take that as a sign that maybe 
you're attempting something unconventional and there might be a better 
approach.

Take this reply as a nudge to think about your design and don't take it 
as criticism, which it certainly is not intended to be.

References:
http://www.railsbrain.com/api/rails-2.3.2/doc/index.html?a=M002227&name=named_scope
http://guides.rubyonrails.org/getting_started.html#rest
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to