Question: I'm trying to insert some bulk of Data to a Particular Column in my Table by using *CSV* file format. My code is as follows:

**Code**:

```
def maritalstatus_migration
   filename = "#{RAILS_ROOT}/config/MaritalStatus_Data_Migration_240114.csv"
   file=File.new(filename,"r")
   while (line = file.gets)
      columns = line.split("$")
      employee = Employee.find_by_employeeid(columns[0].to_s.chomp.strip)
      personnel = Personnel.find_by_extid(columns[0].to_s.chomp.strip)
      if employee && personnel
         sheet_marital_status = columns[1].to_s.chomp.strip
         if sheet_marital_status == 'Married' or 'MARRIED'
            personnel.marital_status = 'Married'
         elsif sheet_marital_status == 'Unmarried' or 'UNMARRIED'
            personnel.marital_status = 'Unmarried'
         elsif sheet.marital_status ='Unknown' or 'UNKNOWN'
            personnel.marital_status = 'Unknown'
         else
            personnel.marital_status = columns[1].to_s.chomp.strip
         end
      end
   end
end     

```

When I run my method in Console,I get a Warning saying:

```
String literal in condition

```

pointing to the line `personnel.marital_status = columns[1].to_s.chomp.strip`, what am i doing wrong.Any Suggestions will be greatly appreciated.

Answer: 
I'd use a `case` statement:

```
personnel.marital_status = case columns[1].to_s.chomp.strip
                           when 'Married', 'MARRIED'
                             'Married'
                           when 'Unmarried', 'UNMARRIED'
                             'Unmarried'
                           when 'Unknown', 'UNKNOWN'
                             'Unknown'
                           else
                             columns[1].to_s.chomp.strip
                           end

```
The `String literal in condition` warning is shewn up, when you have passed the instance of `String` class as a condition for `if` operator, i.e. for example, `x or y`, where `x` is *boolean* (correct), and `y` is `String` (incorrect). Let's see the behaviour of the condition that leads to the warning:

```
if false or "ww12"
   p 1
end

# warning: string literal in condition
1
 => 1 

```

As you can see, the *string literal condition* is always evaluated to `true`. So for most case it could be treated as a syntax error.

In order to fix it just convert the `String` into *boolean*, like `x == 'string'`. And for your code you will get:

```
if sheet_marital_status == 'Married' or sheet_marital_status == 'MARRIED'
   ...
end

```

or with optimizations:

```
if sheet_marital_status =~ /^married$/i
   ...
end

```

**NOTE:** for your case, it will be best to use you `case/when` statement, instead of the `if-elsif-else` statement, because you have homogenic condition in the tree.