Problems connecting Rails to Oracle

Hi
I’m hoping someone can assist me with a problem I’m having connecting to
a local Oracle database:

Running Windows XP Pro. I have Oracle 816 and Oracle 92 clients as well
as Oracle 10g Express DB.

Downloaded Bitnami and OCI8 adapter. I have no problems to connect
Oracle through SQLplus.

This is my database.yml configuration:
development:
adapter: oracle
database: //localhost:1521/XE
username: hello
password: goodbye

The thing is when I try to run scaffolding with rails, it doesn’t work,
and this is that I get from rails console executed via Bitnami
(C:\Program Files\BitNami RubyStack\use_ruby.bat)

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment…
C:/Program Files/BitNami
RubyStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:231:in
establish_connection': Please insta ll the oracle adapter: gem install activerecord-oracle-adapter(no such file to load -- active_record/connection_adapters/oracle_adapter) (RuntimeError) from C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:215:inestablish_connection’
from C:/Program Files/BitNami
RubyStack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:208:in
establish_connection' from C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:234:in initialize_database’
from C:/Program Files/BitNami
RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:94:in
process' from C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in send’
from C:/Program Files/BitNami
RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in
run' from C:/TEMP/RubyPruebas/CodigoRuby/comics_catalog/config/environment.rb:13 from C:/Program Files/BitNami RubyStack/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in gem_original_require’
… 25 levels…
from C:/Program Files/BitNami
RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
from C:/Program Files/BitNami
RubyStack/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' from C:/Program Files/BitNami RubyStack/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require’
from script/server:3

In the session path appears at least three path to Oracle homes:
C:\XXXXXX\oracle10gExpress\app\oracle\product\10.2.0\server\bin;
C:\XXXXXX\ora\e.9.2.0.1.0\bin;
C:\XXXXXX\ORA\E.8.1.6.0.0\bin;

Last but not least, I can connect the Oracle 10g instance that appears
in database.yml through SQLplus via the Ruby console.

I’d appreciate any help, any idea or any suggestion.
Thanks.
Carlos.

I think it’s just the adapter value. I have this

development:
adapter: oci
host: myoraclehost
username: scott
password: tiger

HTH,

Mike

The Oracle adapter isn’t contained by Rails 2.0 by default. So you
have to install it manually. Notice the error message:

Please install the oracle adapter: gem install activerecord-oracle- adapter

Your problem should be solved after the installation of oracle
adapter.

On Jan 17, 7:43 pm, Carlos García azofra <rails-mailing-l…@andreas-

“oci” and “oracle” are both supported for the Oracle adapter in the
configuration.

Liming L. wrote:

“oci” and “oracle” are both supported for the Oracle adapter in the
configuration.

Liming,

I thougt the number of oracle clients or oci8 versions (one for every
client) was confusing rails. Downloaded and installed
ruby-oci8-1.0.0-mswin32.rb, I supposed that was sufficient runing rails
to connect oracle.

Many thanks for your helping. I’ll follow your advice and tell you the
final of the story. If any.

Carlos.

Hi,

This thread [Rails 2.0.1 RC2 - activerecord-oracle-adapter not found - Rails - Ruby-Forum] should solve
your problem

2008/1/17, Carlos García azofra [email protected]:

`establish_connection’
RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in
from C:/Program Files/BitNami
C:\XXXXXX\oracle10gExpress\app\oracle\product\10.2.0\server\bin;
Posted via http://www.ruby-forum.com/.


Best regards,
Jesse

Jesse Hu wrote:

Hi,

This thread [Rails 2.0.1 RC2 - activerecord-oracle-adapter not found - Rails - Ruby-Forum] should solve
your problem

2008/1/17, Carlos Garcí¡ azofra [email protected]:

`establish_connection’
RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in
from C:/Program Files/BitNami
C:\XXXXXX\oracle10gExpress\app\oracle\product\10.2.0\server\bin;
Posted via http://www.ruby-forum.com/.


Best regards,
Jesse

Thank you Jesse, your link got the solution to solve my problem, but I
am afraid I got a new problem, perhaps simplest than first. When I try
to run scaffolding again I receive the next response from the ruby box.

C:\Temp\my_app>ruby script/generate scaffold myApp
C:/Temp/ruby186-25/ruby/lib/ruby/1.8/yaml.rb:133:in load': syntax error on line 18, col 2: host: 127.0.0.1\XE’ (ArgumentError)

The file database.yml shows next configuration:
development:
adapter: oci

database: XE

username: hr
password:hr
host: 127.0.0.1\XE

I’v tried diferent combinations for

      adapter: oracle and oci
      database: XE and localhost\XE
      host: XE and localhost\XE and 127.0.0.1\XE

but always get the same error.

Could you help me?
Thanks in advance, Jesse.

Regards.
Carlos.

2008/1/27, Carlos García azofra [email protected]:

`establish_connection’
RubyStack/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2
/lib/initializer.rb:49:in
Jesse
The file database.yml shows next configuration:
database: XE and localhost\XE

Hi Carlos,

Maybe there is a typo in “127.0.0.1\XE”?
Please use “127.0.0.1/XE” to specify the database. The
config/database.yml
file should look like :

development:
adapter: oracle or oci
database: localhost/XE or 127.0.0.1/XE
username: hr
password: hr

Here http://wiki.rubyonrails.org/rails/pages/HowtoConnectToOracle is
an
article about how to connect to Oracle.


Regards,
Jesse