1. Michael Granger
  2. ruby-pg
  3. Issues

Issues

Issue #153 invalid

Correct syntax for first example

Eric Radman
created an issue

The first example usage on the home page show this as the means of connecting:

conn = PG.connect( dbname: 'sales' )

Which is incorrect syntax, should't it be:

conn = PG.connect( :dbname => 'sales' )

Comments (5)

  1. Eric Radman reporter

    I see, I was tripped up because I'm still on Ruby 1.8. Even after installing Ruby 1.9 it's still confusing

    $ irb19 
    irb(main):001:0> dbname: 'sales'
    SyntaxError: (irb):1: syntax error, unexpected ':', expecting $end
    dbname: 'sales'
           ^
            from /usr/local/bin/irb19:12:in `<main>'
    

    with braces it's more clear

    irb(main):002:0> { dbname: 'sales' }
    => {:dbname=>"sales"}
    
  2. Michael Granger repo owner

    Yeah, neither syntax is valid outside of a hash:

    1.9.3p392 :001 > :dbname => 'sales'
    SyntaxError: (irb):1: syntax error, unexpected tASSOC, expecting $end
    :dbname => 'sales'
              ^
        from /Users/mgranger/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'
    
  3. Log in to comment