Question: ```
value="{{Temp.r1c2t != SS ? '100' : '250'}}"  

```

This code will worked fine.
When am getting value from database it ll show error. 

My code here

```
value="{{Temp.r1c2t != SS ? {{Temp.SSFareAmount}} : {{Temp.SFareAmount}}}}"

```

Answer: 
You can do it with regexp an error's message

```
begin
 x.save 
rescue ActiveRecord::StatementInvalid => e
  if e.message =~ /^PG::NotNullViolation/
    puts 'Error!!!'
  end
  raise
end

```
You might want to re-raise the exception, when the message doesn't match. Otherwise there is not information about the unhandled exception, what might cause problems.