I have a rails app with the config/environment.rb line
config.gem 'authlogic', :version => '2.1.2'
The system gem for authlogic is 2.1.4
The one in my GEM_PATH is 2.1.2
No matter what I try, Rails is only using the 2.1.4 version, which is a problem. How to force rails to use 2.1.2?
Thanks
I recommend using Bundler
i've made a test here, included the gem authlogic, choose to use the 2.1.3 version, and the application ran without problems.
then i've uninstalled the gem (gem uninstall authlogic -v=2.1.3), and my application didn't ran anymore, normal behavior (i'm using rails 2.3.8 for this test)
you could try uninstalling and then installing the gem again
To be safe, uninstall your 2.1.4 version, freeze 2.1.2, then uninstall 2.1.2 too.
Unpack the gems into your rails app. This'll also help in deployment.
rake gems:unpack
Sys admin re-installed some gems and all the problems went away.
Related
I am working on a project that requires Rails 2.3.3. I have Rails 5.2.2 already installed in my system.
I am asking how to install Rails 2.3.3 and work on that project. Any links would be much appreciated.
You can use rvm for different rails applications.
Try this link https://rvm.io/rvm/install.
After installing rvm. in your gem file you can mention your rails version. it will install automatically.
gem 'rails', '~> 2.3.3'
I have the Rails 4.0.0.beta1 installed but I need downgrade to Rails 3.2.13.
I've used gem install rails 3.2 but Rails continues as 4.0.0.beta1.
I searched existing doubts and try to follow the answers however none worked for me.
Think this is a simple doubt and I need to solve.
This answer my question: How to set default rails version for a project?
You have the same problem as listed here.
Here is what worked for me, and should also for you. It's a more general solution that works regardless of your specific version of the Rails beta. Please note that in order to shift back to 3.2.13 (or whatever version you'd like to go back to), you must remove Railties as well as Rails.
Just do:
gem uninstall rails
Then, select the version of Rails 4 you have and delete it.
Then, do:
gem uninstall railties
And do the same thing.
When I uninstalled the Rails 4 version of railties, it told me that dependencies for a couple gems (coffee-rails and sass-rails) wouldn't be met. So I just did the same thing with both of them as I did above, and deleted their Rails 4 versions as well (for example, for sass-rails, I had a version installed called sass-rails-4.0.0.rc1).
And done! The terminal should list 3.2.13 as your current Rails version.
Unless you're using bundle exec, Rubygems will always use the latest installed version of a gem. You need to uninstall the version you don't want.
gem uninstall rails --version 4.0.0.beta1
The answers to gem uninstall rails --version xxx should remove the rails gem just fine.
However, in the event you want or need to have multiple versions of rails available simultaneously, you can use bundler to load the correct versions of gems (as intended).
$ bundle exec rails in the project directory that lists the version of rails in the Gemfile should let you load the required gems without conflict.
Additionally, rvm and its gemset feature could also let you accomplish the same goal without needing to wrap everything with a bundle exec
Rails will use the version specified in Gemfile:
gem "rails", "4.0.0.beta1"
Replace it with the version you'd like to use instead:
gem "rails", "~> 3.2.0"
Of course, you will also need to change your code and config to use the old Rails API.
I had the same problem with Rails 4.0.0 final version. To check what is currently installed you can run the following:
>pik gem list
Then I checked the rails versions. It showed rails 3.2.14 (what I wanted) with railties 4.0.0, 4.0.0.rc2 and 3.2.14.
I then ran
>gem uninstall railties
and uninstalled all other versions except 3.2.14 and now it works well. The problem was that when Rails 3.2 installation is called, the latest (or all) versions of railties is installed.
If you have other versions of rails other tan the one you want, you can removed them with
>gem uninstall rails
and remove the versions of rails you do not want to have.
Try the following in your console. It will update or install rails to the specified version.
gem update rails 3.2.13
I accidentally changed my rails version to 4.0.0. I've tried gem uninstall rails --version=4.0.0.rc1 and install version 3.2.13 but when rails -v it's still version 4.0.0. I then tried gem uninstall rails, which gives me "Successfully uninstalled rails-3.2.13". Thought this was easy to do, but I can't find a simple solution.
Try this:
rvm use <ruby version>
You can also check your installed ruby versions using rvm list and then switch over. Then do:
rvm gemset create rails3.2.13
rvm <ruby version>#rails3.2.13
gem install rails --version=3.2.13
Remove your Gemfile.lock and install rails again. Make sure you specify the version of Rails.
source 'http://production.cf.rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.13'
I am having a problem getting an old Ruby on Rails 2 app that hasn't worked in a year to work.
I'm trying to run rake test:functionals in the root of my project directory, but am getting undefined method 'name' for "SystemTimer":String.
I've pasted everything that I believe relevant to the problem here:
http://pastebin.com/NgBvystZ
Also, when I run rake itself, I get
Errors running test:units!
Not sure how to debug that.
I have copied and pasted everything that I think would be useful to understanding this problem. Your time is greatly appreciated. Thank you.
This is an incompatibility between versions of RubyGems greater than 1.3.7 and versions of Rails less than 2.3.12. There are a few ways to solve this.
Use Bundler
Bundler is easy to install, fixes this problem, and has a number of other advantages as well. I highly recommend it.
Upgrade to Rails 2.3.12 or higher
Rails 2.3.12 fixed compatibility issues with RubyGems 1.8.5 (see release report).
Downgrade to RubyGems 1.3.7
I would not recommended this unless you have no other choice. Use this command: gem update --system 1.3.7. Also, version 1.7.2 has partial compatibility (it will run, but freezing gems will fail and there are likely other issues).
I chanced upon this thread, because I got the following error when migrating some Radiant 0.9.1 installations to a new server:
undefined method `name' for "RedCloth":String
(3) The compromising solution: I haven't tested this personally, but I hear that rails 2.3 with bundler is compatible with the latest rubygems. If you're interested in this solution, see http://gembundler.com/rails23.html for getting bundler to work under rails 2.3.
For me solution 3 was the only option, since we had other apps needing the latest rubygems on the system.
Just install bundler and follow thes steps on this page:
http://gembundler.com/rails23.html
And put this in a file called "Gemfile" in the app root:
source :gemcutter
gem "radiant", "0.9.1"
gem "sanitize"
gem "fastercsv"
gem "rmagick"
gem "rack", "~> 1.1.0"
gem "rake", ">= 0.8.3"
gem "RedCloth", ">= 4.0.0"
gem "will_paginate", "~> 2.3.11"
gem "mysql"
This is just my example. Start with only the first 2 lines, run bundle update and reload the page to see what else you might be missing.
Thank you Ben!
Rails is showing the validation messages on the page as such:
1 error prohibited this {{model}} from being saved
There were problems with the following fields:
{{attribute}} {{message}}
Wanting it to show the model names not these these brackets.
How do I fix it and why's it doing this?
This is a problem with internationalization in rails. One solution that has worked for some is to downgrade the internationalization gem from 0.5.0 to 0.4.2, like so:
sudo gem uninstall i18n
sudo gem install i18n -v 0.4.2
Of course, if you're using RVM to manage your gems, you don't need sudo in the commands above.
The proper solution involves using bundler to manage your gems instead of using the system defaults and the old Rails 2.x method of embedding it into environment.rb. Bundler segregates your application gems from your system gems properly and removes the problems that occur when using i18n versions 0.4.2 and 0.5 along with Rails 2.x and 3.x.
Steps:
Setup bundler for your Rails 2.3 app
http://gembundler.com/rails23.html
In your Gemfile, just completely leave out i18t.
Run 'bundle'
Note: If you do need i18n, just specify the correct version in the Gemfile. Bundler properly segregates your app's gems from your system gems so there will never be the strange behaviors of having both 0.4.2 and 0.5 installed on your system.
if you want to leave both gems installed, another solution is to create config/preinitializers.rb and add the line
gem 'i18n', '0.4.2'
While using Rails 2.3.5, even with config/preinitializers.rb containing
gem 'i18n', '0.4.2
and environment.rb containing
config.gem "i18n", :version => '0.4.2'
I had to uninstall version 0.5.0 of the i18n gem to make this work.