Ruby on Rails Connect Oracle database practices

Source: Internet
Author: User
Tags ruby on rails oracle database

Today I learned about the latest popular Ruby on Rails, feeling like a code generator linking OracleDatabase, I searched for half a day of information. Finally found a way, ^______^.

1. Installation drive

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

Download and run (double-click) Ruby-oci8-mswin inside the *.RB

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 with TNS;

My Oracle is installed on another machine, so configure the following

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

3. CREATE TABLE Considerations

The name of the default datasheet in Ruby on rails is a plural noun, which means if you want to use the following command:

Ruby Script/generate Scaffold Item Manage

Then the name of your datasheet is going to be items (note the S in it) and the location is in the default space of the username in the database.yml that you just made.

I'm using a ruby 1.8.4.

Rails 1.0.0

The table must be created with the name of a field ID, and a {TABLE_NAME}_SEQ sequence for the table should be established, as follows:

such as my Items datasheet, the fields are: ID, Title, Createdat Three, and set up a items_seq sequence (sql:create sequence items_seq increment by 1)

4. Then use Ruby Script/server to see 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.