I have params[:location] that should accept Left PA and Right PA it should not matter if we pass PA Left, Pa LEFT, Pa left, pa left, etc. I have to convert it to Left PA and similar with Right PA.
if params[:source] == 'abc'
'ABC'
elsif params[:source] == 'DEF'
'DEF'
else
params[:source]
end
Can someone help me.
CodePudding user response:
you can use downcase/upcase
method to compare. And instead of if/else
you can use case
case params[:location].to_s.downcase
when 'pa left'
'Left PA'
when 'pa right'
'Right PA'
else
params[:location]
end