Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8857745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:39:58+00:00 2026-06-14T14:39:58+00:00

I have a case statement and I am trying to use the ternary operator

  • 0

I have a case statement and I am trying to use the ternary operator to do additional conditional checking. But it errors out.

here is a sample of the code

case url
when partner_x_url then Rails.env.development? ? partner_signup_url : partner_signup_url :protocol => "https"
.
.
.
else regular_signup_url
end

The really weird thing is that it works if use the following

case url
when partner_x_url then if Rails.env.development?; partner_signup_url; else partner_signup_url :protocol => "https"; end
.
.
.
else regular_signup
end

Any ideas of why this is happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:39:59+00:00Added an answer on June 14, 2026 at 2:39 pm

    You’re missing the ? operator:

    when partner_x_url then Rails.env.development? ? partner_signup_url : partner_signup_url :protocol => "https"
    

    Happens to me all the time with a method ending in a question mark 🙂

    EDIT: Since you now added that operator, I suspect it has to do with operator precedence. Try to avoid those kind of issues with using parentheses around function arguments:

    when partner_x_url then Rails.env.development? ? partner_signup_url : partner_signup_url(:protocol => "https")
    

    Example: Without function parentheses, you get a syntax error:

    1.9.3p125 :006 > case @foo when true then true ? puts "foo" : puts "bar" end
    SyntaxError: (irb):6: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
    case @foo when true then true ? puts "foo" : puts "bar" end
                                          ^                                                ^
    

    With parentheses, you don’t:

    1.9.3p125 :007 > case @foo when true then true ? puts("foo") : puts("bar") end
     => nil 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to use a case statement but keep getting errors. Here's the
Ok here I have a switch case statement which is falling through and trying
I'm trying to use a CASE statement in a SQL query I have and
I have kept hearing this statement. Switch..Case is Evil for code maintenance, but it
I'm trying to figure out how to create a dynamic case statement in a
I'm trying to use a switch statement in Android aplication,where I have to check
i need some help with switch/case statement syntax im trying to use onClick to
I'm trying to use a switch statement to read out what button has been
I have a case statement that returns a date; case when (ma.first_active_date is not
I have a switch case statement that doesn't work. I've checked the input, it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.