title: Rails ActiveRecord Arels: Unsupported argument type: String. Construct an Arel node instead
body: <p>I'm using <code>Arels</code> for creating query. In this query, I use <code>generate_series</code> function. Here is my code: </p>
  
  <pre><code>    def generate_series
        Arel::Nodes::NamedFunction.new('GENERATE_SERIES', [start_date, end_day, '1 day'])
      end
  
  def start_date
        Arel::Nodes::SqlLiteral.new(&lt;&lt;-SQL
           CASE WHEN DATE_PART('hour', NOW() AT TIME ZONE 'ICT') &lt; #{Time.now - 3days} THEN (CURRENT_DATE - INTERVAL '14 days') ELSE (CURRENT_DATE - INTERVAL '13 days') END
        SQL
        )
      end
  
      def end_date
        Arel::Nodes::SqlLiteral.new(&lt;&lt;-SQL
           CASE WHEN DATE_PART('hour', NOW() AT TIME ZONE 'ICT') &lt; #{Time.now} THEN (CURRENT_DATE - INTERVAL '1 day') ELSE CURRENT_DATE END
        SQL
        )
      end
  </code></pre>
  
  <p>When I try to test by <code>generate_series.to_sql</code>. I meet exception:</p>
  
  <blockquote>
    <p>Arel::Visitors::UnsupportedVisitError: Unsupported argument type:
    String. Construct an Arel node instead.</p>
  </blockquote>
  
  <p>I try to shorter my code for testing:</p>
  
  <pre><code>def generate_series
        Arel::Nodes::NamedFunction.new('GENERATE_SERIES', ['19/11/2012', '20/11/2012', '1 day'])
   end
  </code></pre>
  
  <p>The problem is same. Please tell me how can I fix this problem.</p>