装上oracle驱动

前两天看了下ror的东西,觉得很有趣,我也动手来搞一下。

ruby,rails顺手抓下来,netbeans也挺有意思。不过默认ms是mysql,这个可挺没意思,我可是要用oracle

动手吧。

http://www.oracle.com/technology/global/cn/pub/articles/haefel-oracle-ruby.html

 

http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html

sudo vi /etc/profile

export DYLD_LIBRARY_PATH=/opt/oracle/instantclient10_1

http://rubyforge.org/frs/?group_id=256

 

RC_ARCHS=i386
export RC_ARCHS

/oracle/ruby-oci8-2.0.3

make

make install

 

ruby setup.rb config

ruby setup.rb setup

ruby setup.rb install

MD,失败了。。。。

最后发现还是这个靠谱

http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/

sudo vi /etc/profile

export DYLD_LIBRARY_PATH="/opt/oracle/instantclient10_1"
export SQLPATH="/opt/oracle/instantclient10_1"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH=$PATH:$DYLD_LIBRARY_PATH

 

 

 



ORACLE_PATH=/opt/oracle/instantclient10_1
export DYLD_LIBRARY_PATH="${ORACLE_PATH}"
export SQLPATH="${ORACLE_PATH}"
export TNS_ADMIN="${ORACLE_PATH}"
export NLS_LANG="AMERICAN_AMERICA.UTF8"
export PATH=$PATH:$DYLD_LIBRARY_PATH

/oracle/ruby-oci8-2.0.3

 

ruby setup.rb config
make
sudo make install

 

 

 

控制台可以了。。。但是ide里还是不可以,


=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:52820
oci8lib.c:164:in oci8lib.bundle: OCI Library Initialization Error (OCIError)
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/huangbin/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /Users/huangbin/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/huangbin/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /Library/Ruby/Site/1.8/oci8.rb:25
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/huangbin/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
     ... 35 levels...
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/huangbin/Desktop/ror/rorMiniBiz/script/server:3
    from -e:1:in `load'
    from -e:1

Process finished with exit code 1

 

===

追加一行

export ORACLE_HOME=/opt/oracle/instantclient10_1

无效:(

 

唉。。。

原来把昨天加的系统变量在ide里搞一下就可以了。

 

以后生产系统看来还真得需要很多时间阿。

 

 

http://www.iteye.com/topic/191071

 

NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"

 

上边的解决方法无效。。。

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 

回家了,搞的时候发现竟然有乱码问题,nnd,google

http://even.wordpress.com.cn/tag/rails-mysql-utf8/

费了九牛二虎之力,终于搞定了。
Rails下面database.yml,增加配置encoding:utf8
Mysql配置文件:
[mysqld]
default-character-set=utf8
defalut-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci

create database [name] default character set utf8 default collate utf8_general_ci

 

仔细一看原来是创建database的时候不是utf8.。。

好了,天下太平,我要继续了

 

 

 

^^^^^^^^^^^^^^^^^^^^^

 

 

我靠。。。

爽阿

上传文件处理

字符转换           

require'iconv'

usernameutf8 =   Iconv.iconv("UTF-8", "GBK", csvs[4]).to_s


 

 

 

分页will_paginate

model加一句

require 'will_paginate'
 

Controller加一句

@als = Al.paginate :page => params[:page]||1, :per_page => 50
 

页面一句

           <%= will_paginate @alis, :prev_label=> '上一页',:next_label   => '下一页' %>  
 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值