Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:38:50+00:00 2026-05-22T23:38:50+00:00

From the rails postgresql_adapter.rb . I get what it’s trying to do, I just

  • 0

From the rails postgresql_adapter.rb. I get what it’s trying to do, I just don’t get how it happens. It’s really to do with the <<-SQL that I’m lost.

exec_query(<<-SQL, 'SCHEMA', binds).rows.first[0].to_i > 0
  SELECT COUNT(*)
  FROM pg_tables
  WHERE tablename = $1
  #{schema ? "AND schemaname = $2" : ''}
SQL

I’ve seen code before where you could say:

blah = <<-X
 some
 lines
 of
 test
X

But I’ve never seen this done within the argument to a function call. I’m really confused by this. Can someone explain to me what exactly is going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:38:51+00:00Added an answer on May 22, 2026 at 11:38 pm

    You can use a heredoc-marker (like <<-SQL in your example) anywhere (or even multiple times) in a line and the heredoc will then start on the following line and continue until the end-marker is met (in case of multiple markers, the (n+1)th heredoc will start after the nth end-marker and continue up to the (n+1)th end-marker). The content of each heredoc will then be inserted at the place where the corresponding marker was used.

    So

    foo(<<BAR, 42)
    bar
    BAR
    

    is the same as

    foo("bar\n", 42)
    

    and

    foo(<<BAR, <<BAZ)
    bar
    BAR
    baz
    BAZ
    

    is the same as

    foo("bar\n", "baz\n")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to setup a simple timer that gets started from a Rails Application.
In PHP, I'm trying to steal a page from the Rails playbook (see 'Using
How do you execute a SQL statement from Rails 3? For example, the SQL
I'm trying to get Rails to work with PostgreSQL. Apparently one thing I need
I'm trying to run the chapter two demo_app from the Ruby on Rails 3
I am trying to switch my Rails TEST environment from SQLite3 to Postgresql. However,
I'd like to be able to invoke a file download from rails using link
I'm coming from a Rails background and doing some work on a ASP.NET project
I need to produce somewhat complicated PDFs from a Rails app - tables with
How might you call a Lisp program from a Rails application?... For example, allow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.