shaunstanislaus#Master ~/workspace/mongodb_rails_project/sodibee (master) $ rails g mongoid:config
Could not find generator 'mongoid:config'. Maybe you meant 'migration' or 'controller' or 'generator'
Run `rails generate --help` for more options
Okay, I resolved it.
Firstly, my mongoid is outdated and was using 1.0.6, the latest current version is 4.0.1.
Specify in your gems mongoid, 4.0.1
It thus would require you to also include gem 'moped', '2.0.2'.
I am assuming you have bson and bson_ext too.
Then do:
spring stop
spring restart
Lastly, try:
rails g mongoid:config
You should see the new file:
create config/mongoid.yml
The older version get's installed when you don't mention a specific mongoid version and the mentioned rails version does not support the latest mongoid version. In this case, the older mongoid version get's installed.
So if this happens with anyone, check the compatibility chart published by mongoid
https://docs.mongodb.com/mongoid/current/tutorials/mongoid-installation/
Related
Currently Rails 4.0.2 is installed in my Windows machine and I'm using it for several rails projects. But, I do want to use Rails 3.2.8 version for another project.
So, my question: Can I specify the version 3.2.8 on a single project and retain 4.0.2 in all the rest by ensuring all dependencies for 3.2.8 are installed?
Yes !
Install the rails 3.2.8 gem.
Then, you can specify which version of rails you want to use :
rails _3.2.18_ new mySuperSecretProject
In each project, you can use rails _xxx_ console, but it is easier do directly use the binstubs : bin/rails console
Yes you could do it as Intrepidd stated.
Another way to do this is by including a specific gem version in your application Gemfile and then do a bundle install. This will tell the application to use that particular version of rails over your system version
Rails can be installed as follows:
1) Specify the rails gem version in your project Gemfile
gem 'rails','3.2.8' OR gem 'rails', '4.0.2'
2) Try running bundle install. it will automatically install required rails version for you and will create a bundle unique for the project you are in.
3) For rails 4.0.2 project: if rails 3.2.8 is already installed, try running 'bundle update rails' to upgrade the current rails version and it will install all of its dependencies in the corresponding bundle.
If you want to run these projects in different ruby versions, then in Linux platforms RVM is the best option. But, in windows RVM will not work. A good option will be the Pik tool. Pik is a tool to manage multiple versions of ruby on Windows.
Please refer here for the same. Hope it helps :)
I have installed two different version of rails in same gem set. When I do gem list rails it will show as follows:
**rails (3.0.11, 2.3.8)** // This means I have two rails
When I create new rails application it will take latest one, that means app should be created using rails new app_name not using rails app_name.
But I want to use rails 2.3.8 instead of 3.0.11. I know that using RVM helps in switching between different version of rails but they are installed in different gem set. Is there any possibility to switch between different rails version in same gem set?
Thank you.
The later version has higher precedence. You have to be explicit when create app by:
rails _3.0.11_ new my_app
OR
rails _2.3.8_ my_app
I'm assuming you are not using Bundler if you are trying to use 2.3.8, so check your config/enrvironment.rb file and change the RAILS_GEM_VERSION to '2.3.8'
I have installed two different rails versions in my system (Fedora).
gem list -d rails
*** LOCAL GEMS ***
rails (3.0.5, 1.2.1)
Author: David Heinemeier Hansson
Rubyforge: http://rubyforge.org/projects/rails
Homepage: http://www.rubyonrails.org
Installed at (3.0.5): /usr/local/lib/ruby/gems/1.8
(1.2.1): /usr/local/lib/ruby/gems/1.8
Full-stack web application framework.
When i try to create the project like following way ("http://www.nomachetejuggling.com/2008/03/12/using-multiple-versions-of-rails/")
rails 1.2.1 myproject
But, it's not working. So, i checked
rails -v
Rails 3.0.5
So, can you help me, how to create the project with older version and newer version. Is there any way to set the particular rails version as default?
To use an older version than the latest you have installed, just wrap the version number in underscores:
rails _1.2.1_ myproject
I couldn't get matkins' answer to work via RailsInstaller on Windows 7, so I thought I'd post my solution for someone else to benefit from: (I don't have the reputation to offer this as a comment so I'm adding a new answer)
c:\>rails -v
Rails 4.0.0
c:\>rails _3.2.8_ app1 &REM This is going to bug out
Instead, I found this works:
c:\>rails _3.2.8_ new app1 &REM This will work
The URL you posted solves your problem - you simply forgot the underscores.
varar:~ mr$ gem list rails
*** LOCAL GEMS ***
rails (3.1.0.rc1, 3.1.0.beta1, 3.0.3, 3.0.1)
varar:~ mr$ rails _3.0.1_ -v
Rails 3.0.1
As #Shaun mentioned in this post, you can use multiple versions of Rails and Ruby in same time!
For using an specific version of ruby:
rvm use 1.9.3 --default
Switch --default is used for setting this version as Ruby default version.
For using an specific Rails and Ruby version:
rvm gemset create rails-3.2.3
rvm use 1.9.3#rails-3.2.3 --default
gem install rails
First line creates a gemset and related folder under /home/username/.rvm/gems/
Second line use that gemset as default one
Third line install specified version in gemset (Rails 3.2.3) on related folder.
This is my gems folder's contents:
cache ruby-1.9.3-p194 ruby-1.9.3-p194#global ruby-1.9.3-p194#rails-3.2.3
Initial folder is ruby-1.9.3-p194#global. Therefore for backing to previous state, just run:
rvm use 1.9.3#global
and you can see previous Rails and Ruby versions :)
Good luck
To create a project with the specific rails version use the below command:
similar to matkins suggested
rails _5.0.7.2_ new <project_name>
In your config/environment.rb file, place this at the beginning for the old version:
RAILS_GEM_VERSION = '1.2.1'
or this for the new version:
RAILS_GEM_VERSION = '3.0.5'
here is a general format example. feel free to modify as needed
rvm use ruby-2.1.0#rails4.2
You first installed a rvm(rails version management)
then type.
rvm 1.2.1
In my env I require 3.0.3
but when I script/server
I get this: can't activate rails (= 2.3.8, runtime) for [], already activated rails-3.0.3
I don't want it to activate 2.3.8.. =\
Rails 3.x doesn't use script/server anymore - you should run your server with rails server or rails s. You can delete all the files from script, except for script\rails.
Plus, you no longer specify your Rails version in environment.rb (if that's what you mean by "env"). All gems and their versions are specified in your Gemfile.
Did you follow a guide like Upgrading to Rails 3? It's not enough to just change the Rails version in evironment.rb.
The command to run the server in Rails 3 is rails server. What happens if you run that?
Rails 3 uses
rails server
command instead of
ruby script/server
Check environment.rb to make sure that you're not specifying rails 2.3.8 explicitly. If you are then you need to make sure you've upgraded to bundler properly.
My suggestion is to generate an empty rails 3 project and look at how the generated files and make sure your app looks similar.
I had Rails 2.3.5 installed, and wanted to upgrade to 2.3.10 as a stepping stone to Rails 3. I thought running gem install rails -v=2.3.10 would install 2.3.10 and keep 2.3.5 as well. But now when I do rails -v, it only lists Rails 2.3.10. How can I install different versions of Rails and keep the existing ones?
gem list rails should show you all installed versions of Rails. You can specify which one you want each project to use in the config/environment.rb file.
Alternately (or "additionally"), look in to RVM (particularly the "gemset" function) for maintaining separate gem sets for each project.
Updated May 2017 Instead of RVM gemsets, best practice for managing gems in Rails projects (including the Rails gem itself) is to use Bundler. Bundler's Gemfile will list all the gems your project uses, and allows you to "pin" versions, so by changing the version pin for Rails and running bundle you can update your project to the new version.
<sarcasm>Now that I've said that, though, Bundler is probably on the way out to be replaced by something else. </sarcasm>
You still have both versions, as the other answers have mentioned. However, you don't want to call rails newapp and then change the config/environment.rb file. This will cause problems for any files that have changed between versions. Instead, create a new 2.3.5 app this way:
rails _2.3.5_ newapp
And you'll run the exact version of rails you want, to create the file structure correctly. I don't know why this isn't documented better.
To answer your question, you can install many versions of the rails gem without conflict. However, each project is created using a specific version. To install a new version of the rails gem as follow;
Change the version 3.2.18 with any version you like (see link below for all available versions).
gem install rails --version=3.2.18
To install the latest version
gem install rails
To check all the rails version available, check out this link
Here is a link to all the version of rails
You might consider updating your gem software by this command prior to loading new gems.
gem update --system
As per #pjmorse, list the version installed with this command
gem list rails
Hope that helps
You can define the Rails version of an application in config/enviroment.rb.
You can vendor the version of rails you want into your vendor/rails folder. At the command line just run rake `rake rails:freeze:edge RELEASE=2.2.2'. You don't need any version of rails installed for this to work it will take the source and build it from the remote source in your vendor directory.
rake rails:freeze:edge RELEASE=2.2.1
rake rails:freeze:edge RELEASE=2.2.2
rake rails:freeze:edge RELEASE=2.2.3
rake rails:freeze:edge RELEASE=2.2.4
rake rails:freeze:edge RELEASE=2.2.5
rake rails:freeze:edge RELEASE=2.2.6
rake rails:freeze:edge RELEASE=2.2.7
rake rails:freeze:edge RELEASE=2.2.8