Last active
February 27, 2023 00:19
-
-
Save alexishida/bdb7b836be1a8f82a2f54cb6517300bd to your computer and use it in GitHub Desktop.
Rails Oracle Client 18 Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instalar a biblioteca | |
sudo apt-get install libaio1 | |
# Criar a pasta | |
sudo mkdir /opt/oracle | |
# Extrair para /opt/oracle | |
instantclient-basic-linux.x64-18.5.0.0.0dbru.zip | |
instantclient-sdk-linux.x64-18.5.0.0.0dbru.zip | |
# Criar o link simbolico da lib | |
cd /opt/oracle/instantclient_18_5 | |
ln -s libclntsh.so.18.1 libclntsh.so | |
# Exporta as variaveis abaixo: | |
export LD_LIBRARY_PATH=/opt/oracle/instantclient_18_5:$LD_LIBRARY_PATH | |
export PATH=/opt/oracle/instantclient_18_5:$PATH | |
# Criando o projeto no Rails | |
rails new projeto -d oracle | |
# Adiciona no Gemfile | |
gem 'activerecord-oracle_enhanced-adapter' | |
gem 'ruby-oci8' | |
# Instalando as gems | |
bundle install | |
# colocar no config/boot.rb | |
ENV['LD_LIBRARY_PATH'] ||= '/opt/oracle/instantclient_18_5' | |
ENV['NLS_LANG'] = 'BRAZILIAN PORTUGUESE_BRAZIL.AL32UTF8' | |
# Criar um arquivo config/initializers/oracle.rb e inserir o código | |
ActiveSupport.on_load(:active_record) do | |
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do | |
# true and false will be stored as 'Y' and 'N' | |
self.emulate_booleans_from_strings = true | |
# start primary key sequences from 1 (and not 10000) and take just one next value in each session | |
self.default_sequence_start_value = "1 NOCACHE INCREMENT BY 1" | |
# Use old visitor for Oracle 12c database | |
self.use_old_oracle_visitor = false | |
# other settings ... | |
# ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces = | |
# {:clob => 'TSLOBS', :blob => 'TSLOBS', :index => 'TSINDEXES', :table => 'TSTABLES'} | |
end | |
end |
tem algum exemplo do database.yml? tá complicado funcionar aqui usando subsystem no windows
default: &default
adapter: oracle_enhanced
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: 'user'
password: '123'
development:
<<: *default
database: //localhost:1521/dev
test:
<<: *default
database: //localhost:1521/test
production:
<<: *default
database: //localhost:1521/prod
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tem algum exemplo do database.yml? tá complicado funcionar aqui usando subsystem no windows