Ruby on Rails

From Oracle FAQ
Jump to: navigation, search

Ruby is a pure object-oriented programming language with a super-clean syntax that makes programming elegant and fun. Ruby successfully combines Smalltalk's conceptual elegance, Python's ease of use and learning, and Perl's pragmatism. Ruby originated in Japan in the early 1990s. It has become popular worldwide in the past few years as more English-language books and documentation have become available (and its popularity has really taken off since the introduction of Rails).

Rails is an open source Ruby framework for developing web-based, database-driven applications.

Oracle integration[edit]

Rails supports connectivity to Oracle Database versions 8i, 9i, and 10g. To test your Ruby/Oracle connectivity:

ruby -r oci8 -e 'OCI8.new("scott", "tiger", "orcl").exec("select * from emp") do |r| puts r.join(","); end'

Please ensure that the ruby/OCI8 driver (http://rubyforge.org/projects/ruby-oci8/) is installed. If not, an AdapterNotFound exception will be thrown when the web server is started.

Configuring database.yml[edit]

By default Rails is set up to work with MySQL, but you can re-configure it for Oracle by changing the database.yml file in the config directory. Entries should look something like this:

development:
  adapter: oracle
  database: 127.0.0.1/ORCL
  username: scott
  password: tiger

To connect via SQL*Net (an tnsnames.ora entry):

development:
  adapter: oracle
  database: TNSENTRY
  username: scott
  password: tiger

When done, test to ensure the database.yml file is correctly parsed:

ruby -ryaml -e "File.open('config/database.yml') { |f| puts YAML.load(f).inspect }" 

External links[edit]