Install JRuby under Linux

Source: Internet
Author: User

Install Ruby

Cd

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

echo ' Export path= ' $HOME/.rbenv/bin: $PATH "' >> ~/.BASHRC

Echo ' eval ' $ (rbenv init-) "' >> ~/.BASHRC

EXEC $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

echo ' Export path= ' $HOME/.rbenv/plugins/ruby-build/bin: $PATH "' >> ~/.BASHRC

EXEC $SHELL

Rbenv Install 2.3.1

Rbenv Global 2.3.1

Ruby-v

Installing Bundler
gem install bundler
Installing Nodejs
node -vcurl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Installing Rails
4.2.6
rbenv rehash

The version number can be prompted by the tab prompt for the latest version number

First Web site

Using the SQLite3 test:

#### If you want to use SQLite (not recommended)
rails new myapp
 
#### If you want to use MySQL
rails new myapp -d mysql
 
#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
rails new myapp -d postgresql
 
# Move into the application directory
cd myapp
 
# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified
 
# Create the database
rake db:create
 
rails server

Open http://localhost:3000 to see the cover page.

The first crud feature

Rails Generate scaffold person first_name:string last_name:string phone_number:string Address:text

Rake Db:migrate

Rake Db:migrate rails_env=production

Now open Http://localhost:3000/people There is a staff management crud page.

JRuby running the Rails installation Java

Uninstall OPENJDK First:

Yum-y Remove java*

Installing Oracle JDK

sudo rpm-i jdk-8u112-linux-x64.rpm

Installing JRuby

Rbenv Install--list

Rbenv Global jruby-9.1.5.0

Jruby–v

Modify Gemfile

Remove Auto-generated:

Gem ' Activerecord-jdbcsqlite3-adapter '

Add at the end:

Platform:jruby do

Gem ' Activerecord-jdbc-adapter ', git: ' Https://github.com/jruby/activerecord-jdbc-adapter.git ', branch: ' Rails-5 '

Gem ' Activerecord-jdbcsqlite3-adapter ', git: "Https://github.com/jruby/activerecord-jdbc-adapter.git", Branch: ' Rails-5 '

Gem ' Listen '

End

Run

Bundle Install

Jruby–s Rails Server

Install JRuby under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.