Tam
Tam

Reputation: 12042

I have two versions of Ruby (1.8.7 and 1.9) installed how to specify which one for rails? or does it matter

I have Ruby 1.8.7 and 1.9 install. I run the different ones by specifying ruby or ruby1.9 when running commands. for example

ruby --version

or

ruby1.9 --version

however when I want to create new rails application the command available is rails such as:

rails my_app_name

How do I specify when I call the 'rails' command to create new rails app or does it matter? I mean if I create it with one version it will be the same code of the other version or does the generator script user different code for different Ruby versions.

Thanks,

Tam

Upvotes: 3

Views: 2262

Answers (4)

Andrius
Andrius

Reputation: 2818

For unix type OSes. You could also link executables for ruby1.8/1.9 to ruby, gem1.8/1.9 to gem and etc. Something like:

ln -sf /usr/bin/ruby1.8 /usr/bin/ruby
ln -sf /usr/bin/gem1.8 /usr/bin/gem
...

You can find paths to your ruby/gem/rake/etc. executables by using which command. You could alias these commands as use18, use19 for example.

Upvotes: 0

dylanfm
dylanfm

Reputation: 6345

I use passenger/mod_rails for development locally (on Mac OSX Snow Leopard). In the apache (or nginx) conf file where passenger's settings live, you set a "PassengerRuby" environment variable. You can point this to whichever ruby installation you're wanting to use (don't forget to restart apache afterwards).

I'm using RVM at the moment for managing my ruby installations. In my user's apache conf file I've got the default Mac OSX snow leopard 1.8.7 set up with passenger, and then also one for a 1.8.6 installation via RVM. Whichever one I want to use is left un-commented. Here's how it looks at the moment:

# Default passenger
LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.2.5
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

# Use RVM 1.8.6 ruby
# LoadModule passenger_module /Users/dylanfm/.rvm/gems/ruby/1.8.6/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
# PassengerRoot /Users/dylanfm/.rvm/gems/ruby/1.8.6/gems/passenger-2.2.5
# PassengerRuby /Users/dylanfm/.rvm/bin/ruby-1.8.6-p383

Upvotes: 2

khelll
khelll

Reputation: 24010

The simplest way is to use the -S option. For example and according to your case, to use Ruby 1.9 you can do:

# Create new Rails project with Ruby 1.9
ruby1.9 -S rails new_app

# Run the project with Ruby 1.9
ruby1.9 script/server

#install new gems for Ruby 1.9
ruby1.9 -S gem install some_gem

# Use Rake with Ruby 1.9
ruby1.9 -S rake something

And as your default Ruby interpreter is the 1.8.7 one, then just keep the normal use of it, no need for -S option.

Upvotes: 3

BvuRVKyUVlViVIc7
BvuRVKyUVlViVIc7

Reputation: 11811

Doesn't matter, the rails structure is quite the same.

Upvotes: 0

Related Questions