# Help with best approach(fairly easy question)

**URL:** <https://discuss.rubyonrails.org/t/help-with-best-approach-fairly-easy-question/34514>\
**Category:** rubyonrails-talk\
**Created:** [September 19, 2008, 7:50am UTC](https://discuss.rubyonrails.org/t/help-with-best-approach-fairly-easy-question/34514 "2008-09-19T07:50:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elioncho](https://avatars.discourse-cdn.com/v4/letter/e/ed8c4c/32.png) [@elioncho](https://discuss.rubyonrails.org/u/elioncho)\
**Post date:** [September 19, 2008, 7:50am UTC](https://discuss.rubyonrails.org/t/help-with-best-approach-fairly-easy-question/34514/1 "2008-09-19T07:50:38Z")

</div>

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 &nbsp;&nbsp;if params[:category] &nbsp;&nbsp;&nbsp;&nbsp;@posts = Posts.find(:all, :conditions =\> ["category\_id = ?, params[:category]]) &nbsp;&nbsp;elsif params[:user] &nbsp;&nbsp;&nbsp;&nbsp;@posts = Posts.find(:all, :conditions =\> ["user\_id = ?, params[:user\_id]]) &nbsp;&nbsp;elsif params[:tag] &nbsp;&nbsp;. &nbsp;&nbsp;. &nbsp;&nbsp;. end

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

&nbsp;&nbsp;post\_categories controller? post\_tags controller? user\_posts controller?

So, which approach should I use?

Thanks again,

Elioncho

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Fuentealba1](https://avatars.discourse-cdn.com/v4/letter/r/ba9def/32.png) [@Rodrigo\_Fuentealba1](https://discuss.rubyonrails.org/u/Rodrigo_Fuentealba1)\
**Post date:** [September 19, 2008, 7:58am UTC](https://discuss.rubyonrails.org/t/help-with-best-approach-fairly-easy-question/34514/2 "2008-09-19T07:58:21Z")

</div>

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!
