Ruby on Rails connection to Oracle Database

Source: Internet
Author: User

Today I learned about the latest popular Ruby on Rails. I feel that it is a code generator linked to Oracle.DatabaseI checked the data for half a day. Finally, I found a solution. ^ ______ ^

1. Install the driver

Http://rubyforge.org/projects/ruby-oci8/

Download and run (double-click) *. rb in the ruby-oci8-mswin

2. Change database. yml

Development:
Adapter: oci
Host: examplesid
Username: exampleuser
Password: examplepass

Or

Development:
Adapter: oci
Host: 192.168.0.50/examplesid
Username: exampleuser
Password: examplepass

The database field is not used; exampleuser can be replaced by tns;

My oracle is installed on another machine, so the configuration is as follows:

Development:
Adapter: oci
Host: MyTnsName
Username: system
Password: manager

3. Table creation considerations

In ruby on rails, the default data table names are all plural nouns, that is, if you want to use the following command:

Ruby script/generate scaffold Item Manage

The name of your data table is Items (Note S), and the location is the default space of username in the database. yml just created.

I am using ruby 1.8.4.

Rails 1.0.0

When creating a table, you must have a field named ID and create a {table_name} _ seq sequence for the table. The method is as follows:

For example, in my Items data table, the fields include ID, Title, and Createdat, and an Items_seq sequence (SQL: create sequence Items_seq increment by 1) is created)

4. Use ruby script/server to check the results. ^____ ^

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.