Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure JRuby On Rails

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to install and configure JRuby On Rails. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Recently installed Jruby On Rails, found that although there are a lot of information on the Internet to refer to, but due to the continuous update of various components, a lot of information has been outdated, easy to mislead, here to introduce my personal installation process for your reference.

The first is the installation environment, different software versions may lead to different installation results. The environment I use is:

JDK-1.6.0_06

TOMCAT--------------6.0.16

MYSQL---------------5.0.22

JRUBY-1,1

RAILS----------------2.0.2

WARBLER------------0.9.5

Then start the installation, forget the installation of JDK,TOMCAT,MYSQL, and don't forget to configure the JAVA_HOME environment variable.

Next, extract the JRUBY, point the JRUBY_HOME to the extracted file path, and CLASSPATH to the LIB of that path. Next, go to the BIN path of JRUBY and start the following installation

1. Install RAILS and run:

Jruby gem install rails-r-y-- no-ri-- no-rdoc

2. Install the database interface and MYSQL adapter of the Rails framework, and run:

Jruby gem install activerecord-jdbc-adapter-r-y-- no-ri-- no-rdoc

Jruby gem install activerecord-jdbcmysql-adapter-r-y-- no-ri-- no-rdoc

To make it clear here, some materials say that ActiveRecord-JDBC should be installed. In fact, ActiveRecord-JDBC and activerecord-jdbc-adapter are the same thing, but the name has been changed, and the version is different. The version of ActiveRecord-JDBC is 0.5, activerecord. JDBC is now 0. 8. In addition, because activerecord-jdbcmysql-adapter is installed, there is no need to download and install the java language MySQL database interface package.

After the above modules are installed, you can create a RAILS project, for example: jruby-S rails demo

Then modify the config/database.yml, like this:

Adapter: jdbcmysql

Hostname: localhost

Database: test

Username: root

Password:

I would like to add one more point here. Some materials say that they want to modify config/environment.rb and add

If RUBY_PLATFORM = ~ / java/ require 'rubygems' RAILS_CONNECTION_ADAPTERS =% w (jdbc) end

In fact, this change is for the previous version of RAILS2.0, now 2.0.2 has no need to change. This is explained in the activerecord-jdbc-adapter documentation.

After the above settings are completed, you can start WEBrick to run RAILS program. Let's talk about how the RAILS program is deployed to TOMCAT. Goldspike is a little old, and now we can use a better warbler. Run under the BIN path of JRUBY:

Jruby gem install warbler-r-y-- no-ri-- no-rdoc

In this way, warbler is installed, and then if you package it under the RAILS project, you can generate a .war file, but running under TOMCAT will be problematic because warbler does not type the contents of the database connection into the package. In fact, it's not that warbler's BUG,warbler cannot know what kind of database users connect to and how to connect, so you need to configure and modify it yourself.

Jruby-1.1\ lib\ ruby\ gems\ 1.8\ gems\ warbler-0.9.5\ generators\ warble\ templates\ warble.rb files

In the following locations:

# config.gems = ["activerecord-jdbc-adapter", "jruby-openssl"] # config.gems

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report