安装jruby和rails,创建 application - - ITeye技术网站
1) 安装jruby_windows_1_6_0_RC2.exe
2) 配置环境变量
添加JRUBY_HOME=JRUBY安装路径(例如:D:\software\jruby\jruby\jruby-1.6.0.RC2),然后在path中加入%JRUBY_HOME%\bin,在cmd下输入
jruby -v
输出:
jruby 1.6.0.RC2 (ruby 1.8.7 patchlevel 330) (2011-02-09 5434c72) (Java HotSpot(TM) Client VM 1.6.0_20) [Windows 7-x86-java]
(注:如果输出不可执行命令,重启cmd试试,如果再不行,path里面直接加入jruby的安装路径\bin)
3)安装rails,在线安装
A)jruby -S gem install activerecord-jdbc-adapter --no-ri --no-rdoc
B)jruby -S gem install jdbc-mysql activerecord-jdbcmysql-adapter --no-ri --no-rdoc
C)jruby -S gem install jruby-openssl --no-ri --no-rdoc
D)jruby -S gem install rails --no-ri --no-rdoc
然后cmd下输入gem list;
所有的安装插件,是否齐全,不全的话,依照下面的插件名安装,安装命令为:gem install 插件名 (例如:gem install abstract)
abstract (1.0.0)
actionmailer (3.0.5, 2.3.8)
actionpack (3.0.5, 2.3.8)
activemodel (3.0.5)
activerecord (3.0.5, 2.3.8)
activerecord-jdbc-adapter (1.1.1)
activerecord-jdbcmysql-adapter (1.1.1)
activeresource (3.0.5, 2.3.8)
activesupport (3.0.5, 2.3.8)
arel (2.0.9)
bouncy-castle-java (1.5.0145.2)
builder (2.1.2)
bundler (1.0.10)
cgi_multipart_eof_fix (2.5.0)
erubis (2.6.6)
gem_plugin (0.2.3)
i18n (0.5.0)
jdbc-mysql (5.1.13)
jdbc-sqlite3 (3.6.14.2.056)
jruby-jars (1.6.0)
jruby-openssl (0.7.3)
jruby-rack (1.0.8)
jruby-win32ole (0.8.3)
mail (2.2.15)
mime-types (1.16)
minitest (1.6.0)
mongrel (1.1.5 x86-mingw32)
mongrel_service (0.4.0)
polyglot (0.3.1)
rack (1.2.2, 1.1.2)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.5, 2.3.8)
railties (3.0.5)
rake (0.8.7)
rdoc (2.5.8)
rubygems-update (1.6.2)
rubyzip (0.9.4)
sources (0.0.1)
sqlite3 (1.3.3 x86-mingw32)
sqlite3-ruby (1.3.3)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.25)
warbler (1.2.1)
4) 创建application (本机已安装mysql)
jruby -S rails new testapp -d mysql -m http://jruby.org/rails3.rb
打开创建的application
例如我的:E:\testapp\config\database.yml文件,查看下面的内容:
development:
adapter: jdbc ****
encoding: utf8
reconnect: false
database: testapp_development
pool: 5
username: root
password:
# host: localhost
driver: com.mysql.jdbc.Driver ****
url: jdbc:mysql://localhost:3306/testapp_development *****
带有* 号的这几行看看你的是否生成对了???
然后在你的mysql中创建数据库名为testapp_development
5)(可能防火墙会阻止,如果阻止的话,要先关掉防火墙)
jruby -S bundle install
jruby -S rake db:migrate
jruby -S rails s
输出:
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-01-09 10:25:08] INFO WEBrick 1.3.1
[2011-01-09 10:25:08] INFO ruby 1.8.7 (2010-12-03)
[2011-01-09 10:25:08] INFO WEBrick::HTTPServer#start: pid=52852 port=3000
6)之后打开浏览器
输入:http://127.0.0.1:3000/
你将会看到
之后就是导入到netbeans中编写代码了,
在netbeans中新建项目,选择最后一项:如图:
寻找到项目testapp正确路径,点击完成即可;
我也是刚刚学习jruby,希望对大家有用,大家多交流,希望和大家一起进步。。。。