1.Windows環境變量:
JAVA_HOME:D:\Program Files\Java\jdk1.6.0_03
PATH:D:\Program Files\Java\jdk1.6.0_03\bin
2.下載解壓jruby-bin-1.1.4.zip至D:\jruby-1.1.4,增加環境變量:
JRUBY_HOME:D:\jruby-1.1.4
PATH:D:\jruby-1.1.4\bin
3.命令執行
3.1.查看版本:
D:\jrubyapps>jruby -v
jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-08-28 rev 7570) [x86-java]
3.2.
D:\jrubyapps>jirb
4.安裝gem,局域網先從http://rubyforge.org/下載至本地再進行安裝:
4.0.查看:
D:\jrubyapps>jruby -S gem list --local
4.1.下載安裝rails2.1.0:
actionmailer-2.1.0.gem
actionpack-2.1.0.gem
activerecord-2.1.0.gem
activeresource-2.1.0.gem
activesupport-2.1.0.gem
jruby-openssl-0.3.gem
rails-2.1.0.gem
D:\jrubyapps>jruby -S gem install rails-2.1.0.gem -l
4.2.下載安裝mongrel:
daemons-1.0.10.gem
fastthread-1.0.1.gem
gem_plugin-0.2.3.gem
mongrel-1.1.5-java.gem
D:\jrubyapps>jruby -S gem install mongrel-1.1.5-java.gem -l
4.3.使用資料庫mysql和sqlite3,下載安裝JDBC:
ActiveRecord-JDBC-0.5.gem
activerecord-jdbc-adapter-0.8.2.gem
activerecord-jdbcmysql-adapter-0.8.2.gem
activerecord-jdbcsqlite3-adapter-0.8.2.gem
jdbc-mysql-5.0.4.gem
jdbc-sqlite3-3.5.8.gem
D:\jrubyapps>jruby -S gem install jdbc-mysql-5.0.4.gem -l
D:\jrubyapps>jruby -S gem install jdbc-sqlite3-3.5.8.gem -l
5.創建應用:
D:\jrubyapps>jruby -S rails dms
6.查看rake
D:\jrubyapps>cd dms
D:\jrubyapps\dms>jruby -S rake -T
7.使用Oracle資料庫:下載 ojdbc14.jar ,放到 $JRuby_HOME/lib/ 下面.
7.1.修改environment.rb
if RUBY_PLATFORM =~ /java/ require 'rubygems' gem 'activerecord-jdbc-adapter' #require 'active_record/connection_adapters/jdbcmysql_adapter' require 'jdbc_adapter' end
7.2.修改database.yml
development:
adapter: jdbc
driver: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@192.168.0.1:1521:sid
username: dmstest
password: practice
8.首次建立Table:schema_migrations
D:\jrubyapps\dms>jruby -S rake db:migrate
9.啟動server
D:\jrubyapps\dms>jruby script/server
10.瀏覽:http://localhost:3000/
11. 將應用打包成WAR
11.1.安裝warbler gem:
jruby -S gem install warbler
11.2.生成warbler配置檔
jruby -S warble config
11.3.修改config/warble.rb:
config.gems = ["activerecord-jdbc-adapter", "jruby-openssl"]
11.4.配置Weblogic,創建一個JDBC datasource
Name: dms_ds
JNDI name: jdbc/dms_ds
Databse type: Oracle
Database driver: oracle.jdbc.OracleDriver
URL: jdbc:oracle:thin:@192.168.0.1:1521:sid
11.5.配置Rails application,修改config/database.yml
production:
adapter: jdbc
jndi: jdbc/dms_ds
11.6.用warble將應用打包成WAR:
jruby -S warble