我正在使用 ROR 并且在我的控制器功能中我收到了这些参数的参数和基础,我需要根据条件执行操作。但我看到这些是大约 18 个条件。
我怎样才能干这个代码。
if params[:topic] == "Topic (title)" and params[:sort] == "Date (ASC)"
# custom code
elsif params[:topic] == "Topic (title)" and params[:sort] == "Date (DESC)"
# custom code
elsif params[:topic] == "Topic (title)" and params[:sort] == "Topic (ASC)"
# custom code
elsif params[:topic] == "Topic (title)" and params[:sort] == "Topic (DESC)"
# custom code
elsif params[:topic] == "Topic (title)" and params[:sort] == "Author (ASC)"
# custom code
elsif params[:topic] == "Topic (title)" and params[:sort] == "Author (DESC)"
# custom code
elsif params[:topic] == "Post (body)" and params[:sort] == "Date (ASC)"
# custom code
elsif params[:topic] == "Post (body)" and params[:sort] == "Date (DESC)"
# custom code
elsif params[:topic] == "Post (body)" and params[:sort] == "Topic (ASC)"
# custom code
elsif params[:topic] == "Post (body)" and params[:sort] == "Topic (DESC)"
# custom code
elsif params[:topic] == "Post (body)" and params[:sort] == "Author (ASC)"
# custom code
elsif params[:topic] == "Post (body)" and params[:sort] == "Author (DESC)"
# custom code
elsif params[:topic] == "Author" and params[:sort] == "Date (ASC)"
# custom code
elsif params[:topic] == "Author" and params[:sort] == "Date (DESC)"
# custom code
elsif params[:topic] == "Author" and params[:sort] == "Topic (ASC)"
# custom code
elsif params[:topic] == "Author" and params[:sort] == "Topic (DESC)"
# custom code
elsif params[:topic] == "Author" and params[:sort] == "Author (ASC)"
# custom code
elsif params[:topic] == "Author" and params[:sort] == "Author (DESC)"
# custom code
end
非常感谢