How to bind rvm with eclipse's settings - ruby-on-rails

I'm developing using multiple ruby instances and gemset for different apps. In order to switch between my ruby versions and gemsets, I use the .rvmrc file. I also use Eclipse with the radrails plugin as my development tool. Is there any way to get eclipse to switch automatically between the different gemsets and ruby version using rvm?

Go into your project directory and create a file called .rvmrc containing the line:
rvm use ruby-1.8.7-p330#testing --default
(or whatever ruby version/gemset you like)
now do
cd ..
cd -
answer "y"
and now Eclipse should use the specified ruby version
(maybe you need to restart Eclipse first).

Related

Ability to switch between Ruby on Rails versions, one from rbenv, other from rvm

I first used rbenv to install ruby ver 2.2 and Rails ver 4.2 on Linux CentOS 7, then used rvm to install ruby ver 2.4 and rails ver 5.2. Is there a way to switch between these easily or do they both have to be installed using the same method for this to work?
Better you can use rvm. Rvm is the better tool to switch between many versions with the command
rvm use ruby-2.5.1 or rvm use 2.5.1
For list out all rvm just use
rvm list
within rvm, you can manage the versions nicely no need of rbenv here.
I prefer RVM, it's easy to switch between version, also you can use multiple rails version for that ruby easily
install rvm, install ruby and create a gemset with rvm use 2.4#rails_5_2 --create will create a gemset with name rails_5_2
for switching between versions. I use .ruby-version and .ruby-gemset files in my project so i don't need to specify version all the time
in the .ruby-version file write the ruby version
2.4
and inside ruby-gemset write gemset name
rails_5_2
so whenever you will run the project it takes ruby and rails version from there
you can create this two file manually or you can run this command in terminal from your application directory which will create this two files
rvm --ruby-version use 2.4#rails_5_2
I fixed this by removing RVM and installing the newer versions with rbenv instead. Having both versions installed with the same method allowed it to be easy to switch when needed. The shims automatically use the correct Rails versions for each project respectively. As far as I can tell, the Rails versions are locked in with whichever one you started the project with. You can switch the Ruby version for each project by using:
# rbenv local 2.4.1
I chose rbenv over rvm because I read several articles of people praising rbenv's lightweight approach and ease of use over rvm.
NOTE: the "#" character is the beginning of the command line in Linux CentOS 7, NOT a character that you type in.
EDIT: Thank you guys for the recommendations, though. It got me to look more into using rbenv vs. rvm.

RVM's current and default version isn't actually being used

I am running my rails app from a virtualbox build by vagrant using puppet scripts. Every time I login to the box, I have the following problem:
When I run rvm list one of the things it lists is the following:
=* ruby-2.1.1
But when I try to run rails console, it tells me I need to install missing gems. When I run rvm use default, and then run rails console, it works. Why is the default and current setting in rvm not working--why do I have to go to the extra step of also telling rvm which ruby version to use?
Note: I do have a .ruby-version file with 2.1.1 in it. I'm using rvm version 1.25.25
Because you have to tell rvm which version to use.
In earlier version of rvm we have to define .rvmrc file which mention which ruby and gemset to use.
In recent version of rvm we have to define .ruby-version file with ruby version in it and .ruby-gemset file with the name of gemset.
If you just want a quick solution then in your rails directory make a .ruby-version file with content 2.1.1
correct syntax is:
rvm --default use ruby-2.1.1#global
This command sets ruby to selected default permanently. All new terminals will use your default Ruby. Also you don't mention anything about gemset, so I presume global would exist if you didn't mess up your setup.
This solved it:
I added rvm use --default to the machine's ~/.bashrc file.

newbie: Rails, swtich to another rails edition

I am using Rails v2.3 for my project. Then I decided to use Rails Enterprise Edition.
So, I installed Rails Enterprise Edition in RVM.
But after that, how to tell my project to use this new installed Rails enterprise edition?
work woth RVM very simple!
You could see list of all installed ruby versions by typing
rvm list
To set one of them as current call:
rvm use ree
If you are using gemsets call this:
rvm use mygemset#ree
After selecting current ruby version you could again check "rvm list". Near current ruby version there will be arrow.
If you would like to use specific version of ruby in special folder, than put file called ".rvmrc" in that directory (I placed this file in each project root) with content:
rvm use mygemset#ree
See more info at official RVM site http://beginrescueend.com/rvm/basics/

How can I use multiple versions of rails in the same machine

I have installed rails 3.0.10 and 2.3.5 in my machine. I wanna shuffle between them but I am unable to use 2.3.5. When I run a command, the system recognizes only 3.0.10.
rvm lets you easily manage multiple installs of Ruby, each with their own list of gemsets.
Edit: Based on your comment about looking into gemsets, I'll point out one of the single coolest features with rvm. Once you get your gemset setup, create a .rvmrc file in your Rails root directory. Add the following to it:
rvm 1.9.2#foo
Where "1.9.2" is whatever Ruby you're using and "foo" is the gemset name. rvm will automatically start using this set when you cd in to that directory.
Definitely use rvm, create a .rvmrc file in the root directory of each of your projects.
For rails 3 stuff, it should contain a single line: rvm 1.9.2#projectName
Replacing projectName with an identifier for your project. Then use rvm gemset create projectName
Everytime you go into that directory, you'll be using that version of ruby with that particular gemset so you won't mix up versions or ruby or gems!

Controlling ruby version used in Rails

I have an app using Rails 3.0.6 which I run on two machines. I started with ruby 1.8.7 and recently installed ruby 1.9. I swapped my link in '/usr/bin/ruby' to point to the 1.9 install. When I run 'ruby --version' I get the 1.9. However, in my rails app, when I check 'RUBY_PLATFORM' it shows rails is running with 1.8.7.
How do I tell Rails which ruby environment to use? Strangely, this is not the easiest thing to search for. Probably because I don't know enough about it to form a specific question.
https://rvm.io/rvm/install
Install RVM using these instructions, then you can manage and switch between different Ruby versions and gemsets very easily. Using RVM you can have both 1.8.7 and 1.9.x (or any other version) on your system without having to constantly manually change your path and ruby alias.
Older versions of RVM used the .rvmrc file to automatically switch the ruby within a directory. Newer versions use the .ruby-version file.
To switch between rubies, just type rvm use 2.0.0 or whatever version it is you want to use. For ongoing projects it's a good idea to add the .ruby-version file in the root of the directory that contains the version string you want to use, i.e.
2.0.0

Resources