I'm looking to clean up my controller, as it seems heavy and redundant. Any help on how I'd go about moving this type of logic into my model would be appreciated. Thanks for any help on this - the code below is my for index action:
case params[:find_by]
when 'topic'
nuggets = Nugget.where(['topic = ?', params[:topic_name]])
@nuggets = nuggets.paginate(:page => params[:page],:per_page => 15)
@title = nuggets.first.topic
when 'audience'
nuggets = Nugget.where(['audience = ?', params[:audience_name]])
@nuggets = nuggets.paginate(:page => params[:page], :per_page => 15)
@title = nuggets.first.audience
else
@nuggets = Nugget.paginate(:page => params[:page], :per_page => 15)
end