Where to start for Jruby on rails? - jruby

Any tutorials or blog are available to start with JRuby on Rails
which guide me to the installation and small JRuby on Rails application ?
I have gone through this Walkthroughs And Tutorials(https://github.com/jruby/jruby/wiki/WalkthroughsAndTutorials) link but most of the JRuby on Rails links are broken.

JRuby and Rails Installation
The easiest way to set up JRuby is using rvm. The following command installs rvm, the latest version if JRuby, and gets the latest version of rails:
$ curl -L https://get.rvm.io | bash -s stable --autolibs=3 --ruby=jruby --gems=rails
On Windows, you can download an installer which will set up JRuby for you. You then need to install rails by running the following command:
jruby -S gem install rails
Set up a Rails project
JRuby’s wiki page JRuby on Rails is a great collection of resources on the topic; it contains in particular a link to that good blog post: http://blog.rubyrockers.com/2011/03/rails3-application-jruby/
In a nutshell, to create a rails project based on JRuby, use the following command, replacing my_app with the name of your project:
rails new my_app -m https://www.jruby.org/templates/default.rb
Rails Development
Once your project is set up, any Rails 3 tutorial will do — it is Ruby after all!
Deployment
For deployment, have a look at:
“specific” solutions like Torquebox or Trinidad,
or warbler to package your app as a war and deploy in traditional Java app server (WebSphere, Weblogic, etc.).
Further Resources
Finally, it is also worth mentioning that Charles Nutter et al's book Using JRuby has a chapter dedicated to JRuby on Rails, and is an invaluable help in JRuby developments.

Related

Is using -S with JRuby recommended even when using a Ruby version manager?

Based on this page on the JRuby wiki and other resources I see the recommendation is
to always use jruby -S.
because
The -S parameter tells JRuby to use its version of the installed binary, as opposed to some other version (such as an MRI version) that might be on your PATH.
Using rbenv and rvm I've had issues when using -S with JRuby (see this question) and my understanding is that both those version managers solve the problem -S attempts to address.
You do not need to run the gem command with jruby -S gem if you are using a Ruby manager such as rbenv or rvm. Those tools manage your command path for you so that the correct Ruby runtime and the correct version of rubygems are used. Similar applies to the rake.

How to have an old version of Ruby on Cloud9

I have a source code that I want to test on Cloud9 hosting (I have premium account). However, the problem is that the source code is bade on Ruby 1.8, mysql-essential-5.0 and other old libraries.
How can I create a plain VM on cloud9 and install ruby and other version by myself ? So far all i see that all vms are pre-configured with ruby 4
Cloud9 IDE comes with rvm preinstalled, so this is nice. Otherwise, all VM are pre-configured with Ruby 2.1.5 (not 4) and Rails 4.1.6
The only thing you have to do in your console is :
# Check your actual Ruby version
ruby -v
# ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
# Install ruby 1.8 (if it's not already done)
rvm install ruby-1.8
# Switch ruby version
rvm use 1.8
For MySQL I would first do an uninstallation of your current version of mysql with sudo apt-get uninstall mysql* and then install it from source. You can check this link for more info.

reuse shared/bundle between mri ruby and jruby?

I'm using capistrano to deploy a rails app, and it uses bundle install --deployment to put the gems in shared/bundle. I've put the appropriate platform :ruby and platform :jruby blocks in my gemfile, my question is if I switch rvm to jruby and then go to my app root directory and do another bundle install --deployment, will that mess with any of the existing gems there and replace them with jruby ones? Will I be able to switch back to mri and run the app like I always have? Will both platform's gems be in there, and then what about gems like nokogiri that have java versions, will that overwrite the mri version? Will I be able to just switch rvm versions and run the app via mri or jruby as I please at that point?
Turns out mri gems are installed in shared/bundle/ruby and jruby gems in /shared/bundle/jruby, so totally safe to switch to jruby, install your gems, and try it out

jruby: No such file or directory -- rails (LoadError)

I was trying to create a jruby application using jruby -S rails new OSTH_GGG.
But it returns jruby: No such file or directory -- rails (LoadError).
What is the problem?
Make sure the rails gem is installed:
jruby -S gem install rails
See also this answer to get more details on how to get started with JRuby on Rails.

How to install Ruby on Rails with mysql and get it working, a step by step guide?

Some time ago I managed to get RoR working on Windows XP.
I've been trying to get it working on Windows 7 for 2 days but there's just no way, there's always a problem, one that google can't answer, no matter what I try.
Can someone give me a guide or something to get it working on Windows 7 or XP ? Even Ubuntu but I'd rather not go through that maze again.
I figure I'm going to install Windows XP on a virtual machine and start from there.
I need RoR and mysql - what versions, where do I download them from and what steps do I take ?
On a side note, how do you install mysql2 (version < 0.3) on rails 3.0.7 ? Because it automatically tries something over 0.3 which doesn't work on rails 3.0.7 and if I try the gemfile bundle trick with 0.2.7 I don't know how to specify configuration options and of course it doesn't work if I don't give it the location of mysql lib and include directories.
Also I tried using rails 3.1 beta and everything goes smoothly until I start the server and the website never loads on localhost:3000.
This is basically what I do to install on Windows 7:
Download and install latest mysql from http://dev.mysql.com/downloads/mysql/
Install Ruby http://rubyinstaller.org/downloads/ (check the box to update PATH)
Install Ruby Devkit http://rubyinstaller.org/downloads/ (for example extract to C:\DevKit)
Setup Devkit
cd [MY_DEVKIT_INSTALL_DIR]
ruby dk.rb init
ruby dk.rb install
Copy libmysql.dll from your mysql/bin install to C:\Ruby192\bin
gem install rails
gem install mysql2 -v 0.2.6
rails new my_test_app -d mysql
To setup Rails on windows, just download and click:
http://railsinstaller.org/
Take a look at http://rubyinstaller.org/ it should get you up and running.
I like Aptana Studio 3 for developping with RoR on Windows 7. The book "Agile Web Development with Rails" is also full of good advices.
Here are the steps I followed:
1- Installing Ruby via RubyInstaller
2- Install MySQL (follow #Reuben Mallaby instructions)
3- Install Rails
With the Built-in Terminal, make dev' easy. You should take a look: Aptana Studio