私は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
大変感謝します