title: Cannot connect my rails app to Oracle
body: <p>I have a server running Oracle, IP is 192.168.1.50.</p>
  
  <p>On my linux box, I need to connect to this Oracle server. I then installed Oracle Instant client and set the environment variables accordingly:</p>
  
  <p>OCI_INCLUDE_DIR=/home/luc/instantclient_11_2/sdk/include<br>
  LD_LIBRARY_PATH=/home/luc/instantclient_11_2<br>
  DYLD_LIBRARY_PATH=/home/luc/instantclient_11_2/<br>
  OCI_LIB_DIR=/home/luc/instantclient_11_2<br>
  ORACLE_HOME=/home/luc/instantclient_11_2  </p>
  
  <p>I have also installed the appropriate gem:</p>
  
  <pre><code>ruby-oci8 (2.1.0)
  </code></pre>
  
  <p>Once I've defined my models and ran rake db:migrate I got the following error message:</p>
  
  <pre><code>rake aborted!
  ORA-12154: TNS:could not resolve the connect identifier specified
  oci8.c:360:in oci8lib_191.so
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/ruby-oci8-2.1.0/lib/oci8/oci8.rb:123:in `initialize'
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:319:in `new'
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:319:in `new_connection'
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:429:in `initialize'
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in `new'
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:24:in `initialize'
  /home/luc/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-oracle_enhanced-adapter-1.4.1/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in `new'
  ....
  </code></pre>
  
  <p>my database.yml is:</p>
  
  <pre><code>development:
    adapter: oracle_enhanced
    host:  192.168.1.50:1521/orcl
    username: USER
    password: PASS
  </code></pre>
  
  <p>sqlplus connection works perfectly though:</p>
  
  <pre><code>sqlplus USER/PASS@192.168.1.50:1521/orcl
  
  SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 21 17:34:26 2012
  
  Copyright (c) 1982, 2011, Oracle.  All rights reserved.
  
  
  Connected to:
  Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
  With the Partitioning, OLAP, Data Mining and Real Application Testing options
  
  SQL&gt; 
  </code></pre>
  
  <p>Is there something missing in this conf ?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have tested from command line and the connection is working fine:  </p>
  
  <p>ruby -rubygems -e "require 'oci8'; OCI8.new('USER','PASS','192.168.1.50/orcl').exec('select * from users') do |r| puts r.join(','); end"</p>
  
  <p>=> OK</p>
  
  <p>Same thing from irb:  </p>
  
  <pre><code>ActiveRecord::Base.establish_connection(:adapter =&gt; "oracle_enhanced", :database =&gt; "//192.168.1.50/orcl",:username =&gt; "USER",:password =&gt; "PASS")
  </code></pre>
  
  <p>=> OK</p>
  
  <p>but still not working from my rails app.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Using database instead of host fixed the thing:  </p>
  
  <pre><code>development:
    adapter: oracle_enhanced
    database:  //192.168.1.50:1521/orcl
    username: USER
    password: PASS
  </code></pre>