title: SQL query to Rails query (Case Statement)
body: <p>This is my SQL query:</p>
  
  <pre><code>SELECT
    user_id,
    CASE responsible WHEN 1 THEN "true" ELSE "false" END AS responsible
  FROM user_departments
  </code></pre>
  
  <p>How do I write this in rails? I tried a query as below:</p>
  
  <pre><code>Department.first.users.joins(:user_departments).select("users.*, CASE WHEN user_departments.responsible = 1 THEN true ELSE false END AS responsible")
  </code></pre>
  
  <p>but it does not work. How do I correct this query?</p>