Q:

Rails ActiveRecord trigger query for each parameter passed?

How can I trigger a different rails ActiveRecord query each time a parameter is sent to controller?
 if params[:sort].present?
    sort_input = ['foundation', 'originality', 'dynamics', 'execution', 'battle', 'votes']
    @foundation = if sort_input[0].include?
    #here model.order...ActiveRecord query
    end
    @originality = if sort_input[1].include?

    end
    @dynamics = if sort_input[2].include?

    end
    @execution = if sort_input[3].include?

    end
    @battle = if sort_input[4].include?

    end
    @votes = if sort_input[5].include?

    end

A:

Use case statement
case params[:sort]
when 'foundation'
  @foundation = # query goes here
when 'originality'
  @originality = # a different query goes here

..
else
  # an else case
end

