我的控制器中有以下内容:
@filt= params[:filter] || 'no_filter'
if params[:subcategory].nil? || params[:subcategory] == "null"
@resources = Resource.find_by_category(params[:category]).approved.send(@filt).page(params[:page]).per(30)
else
@resources = Resource.find_by_category(params[:category]).find_by_subcategory(params[:subcategory]).approved.send(@filt).page(params[:page]).per(30)
end
我想减少这段代码,以免重复?