Help with best approach(fairly easy question)

Hello!

Well this is maybe a fairly easy question. I am writing an app where users that belong to a group have their own blog where they can make posts. I have a posts_controller with all the CRUD operations and my index action shows all the posts from all the users on a group. The route is:

users/1/posts

The thing is that I want to show too, all the posts from any user, or all the posts for a given tag or category. So my question is, which option should I use:

1) Should I send some extra parameters to my index action, like and id or something:

users_posts(user.id,{:category => 1})

and check on the controller which posts should be shown (for a user, group, tag, category etc...)

Something like this:

def index   if params[:category]     @posts = Posts.find(:all, :conditions => ["category_id = ?, params[:category]])   elsif params[:user]     @posts = Posts.find(:all, :conditions => ["user_id = ?, params[:user_id]])   elsif params[:tag]   .   .   . end

2) Should I create different controllers with only an index action on it (Create and other actions stay on the posts_controller):

  post_categories controller? post_tags controller? user_posts controller?

So, which approach should I use?

Thanks again,

Elioncho

I think you should use your first. It's a bit more coding, but you have your code in just one controller, so you can modify only one part and not a lot of actions, controllers et al.

Cheers!