I want to use constant of an array in SQL heredoc like:
ROLES = ['admin', 'staff', 'guest']
query = <<-SQL
SELECT * FROM users
WHERE role IN (#{ROLES})
SQL
ActiveRecord::Base.connection.execute(query)
but getting syntax error
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "["
LINE 2: WHERE role IN (["admin", "staff", "guest"])
^
ActiveRecord::Base.connection.executefor such a query?ActiveRecord::Base.connection.execute(query)just to demonstrate the situation.