K
K
khataev2013-12-23 22:32:59
Ruby on Rails
khataev, 2013-12-23 22:32:59

Rbenv and various versions of ruby/rails?

Hello!
I started to study rails, more precisely, I continue - I just finished courses from edx.org on saas / rails. But now I'm trying to go through the installation and configuration of the project myself from scratch - there were already ready-made project templates in the courses, so now I'm closing the missing gaps. I have a general idea of ​​rvm/rbenv/bundler. I read the corresponding post on Habré . But here’s what I don’t quite understand: I have two versions of Ruby installed via rbenv: 2.0.0 and 1.9.3. I switch between them - everything is ok. But with different versions of the rail, it's not entirely clear to me. I install the latest version, 4.0.2, into the system. At the time of installation, the Ruby version was selected - 2.0.0 (rbenv global 2.0.0-p353). Switched to Ruby 1.9.3 (global). I'm trying to create a new rails project (rails new app) and I get an error:
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.0.0-p353
So you need to install rails in both versions of Ruby? Will there be any conflicts?
What I want to say: I know that rails are installed as a gem, and if all the necessary gems are defined in the project folder in the Gemfiles file, then they can be installed in isolation only for this project via bundle install. And rails too. BUT - this is when the project is already ready and I transfer it to another computer / server. And when is the initial formation of the template structure of the project? To run, I need to have the rails installed, and here it turns out that the question arises in front of me in which version to install them? All or one is enough? Further, if I want to create projects on different rail versions, will it be enough for me to install the latest one, and create projects on the previous ones, explicitly specifying the version when creating the project? (rails _version_ new appname).
I understand that my question turned out to be a little vague and actually resulted in several, but please help me put everything on the shelves.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
progenth, 2013-12-25
@khataev

but with rbenv rails binds to the version of ruby ​​chosen at the time of installation

I think this logic of work is more than appropriate and correct. What if gem rails were available for all versions of ruby? 4th rails and 1.8 ruby...)
In rvm, you can create gemsets and put gems in them, which will be available if the gemset is active. (By the way, such functionality is implemented in rbenv by a plugin.)
If there is a bundler, nafig gemsets...

K
khataev, 2013-12-24
@khataev

I understand that one should strive to create a set of gems for each application, but my main question was how to create a project template? After all, to do this, you first need to install rails not in some specific project directory (because it doesn’t exist yet =) ), but in the system? It is so? I don't know how when using RVM, but with rbenv rails binds to the version of ruby ​​chosen at the time of installation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question