You'll be better off following the convention of "fat models, skinny controllers", meaning you should put this kind of logic in the model itself. The Post
class should be able to report which posts correspond to your conditions, so you can define a method to do that:
class Post < ActiveRecord::Base
...
def self.by_category_and_type(category = nil, type = nil)
return where(category: category, type: type) if category && type
return where(category: category) if category
return where(type: type) if type
all
end
...
end
Then in your controller you can just call
@posts = Post.by_category_and_type(params[:category], params[:type])
I haven't tested this, but I think it should do the trick. Let me know if it doesn't!