Forum: Ruby on Rails What is the best approach?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2008-11-11 17:51
(Received via mailing list)
Hello everyone,

I am working on an app where the url needs to begin with the group_id
because the user will always navigate inside a group, its events and
posts.

http://xxx.com/groups/1...

My question is:

What is the best way to separate the group posts from the posts that a
particular user created for that group.

I am using right now the posts index to show all the group posts. Now
I want to show all the posts from a specific user on that group.

1) Should I create a new controller ?
2) A new action for the posts controller ?
3) Or maybe send an extra param to the posts index action to know if I
should display the group posts or the user posts on the group.

That's the three choices I have think about, what its the best thing
to do or is there any other option?

Thanks,

Elias
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2008-11-11 22:40
(Received via mailing list)
Any ideas?
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2008-11-11 23:29
> Any ideas?
Have you looked into nested resources?

GET: http://xxx.com/groups/1/posts

POST: http://xxx.com/groups/1/posts

PUT: http://xxx.com/groups/1/posts/1

DELETE: http://xxx.com/groups/1/posts/1

routes.rb
--------------------
map.resources :groups has_many => :posts
This topic is locked and can not be replied to.