0

I have this line of code that only has 2 options. If it is Provider Payments then use the provider_payments_work_lists_path else use the duplicate_claims_work_lists_path. Now I want to include a potential 3rd path. if the name == "Reimbursed Claims" then path them to reimbursed_claims_work_lists_path. How can I do that? Currently I have:

url = (workList.work_list_name == "Provider Payments") ? provider_payments_work_lists_path : duplicate_claims_work_lists_path
1
  • 2
    Ternary assignments are meant for simple conditions as a way to improve readability and reduce code bloat. If you're comparing 3 conditions, you're better off ditching the ternary assignment to keep the readability. Commented Jul 22, 2016 at 16:49

1 Answer 1

5

Just use a case statement:

url = case workList.work_list_name
      when 'Provider Payments'
        provider_payments_work_lists_path
      when 'Reimbursed Claims'
        reimbursed_claims_work_lists_path
      else
        duplicate_claims_work_lists_path
      end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.