ruby - Rails ActiveRecord trigger query for each parameter passed? -


how can trigger different rails activerecord query each time parameter sent 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 

use case statement

case params[:sort] when 'foundation'   @foundation = # query goes here when 'originality'   @originality = # different query goes here  .. else   # else case end 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -