upgrading rails app from 1.8.7 to ruby 1.9.3 - ruby-on-rails

I have a rails application running rails 3.0.20 and ruby 1.8.7
i want to upgrade to 1.9.3.
the stages i toke in order to start the process are so:
rvm user ruby-1.9.3
rvm gemset create upgradegems
rvm use ruby-1.9.3#upgradegems
now... i ran bundle. and i have a conflict with the twitter gem and the omniauth gem
so i updated them both.
then ran bundle again and it succeeded
now what?..
i tried running
rails s
and i got this error:
ruby-1.9.3-p194#amazonto/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library': uninitialized constant Gattica::Auth::VERSION (NameError)
what am i doing wrong? and how do i fix?
thanks

Its not really your code, but its the library you are using Gattica, it wasn't updated for three years, try to put this on your Gemfile
gem "gattica", :git => "https://github.com/chrisle/gattica.git"
That's a fork that works great with ruby 1.9.x

Related

'rails s' throwing error

I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server

Cannot create new rails 3.2.6 site

I have installed ruby 1.9.3p194. I have also installed rails 3.2.8,3.2.6,and 3.0.3. I am able to create a new site using rails versions 3.2.8 and 3.0.3. When I try to create a site with rails 3.2.6 it rails to work.
rails _3.2.6_ new example
/Users/Dave/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb:317:in `bin_path': can't find gem rails (["3.2.6"]) with executable rails (Gem::GemNotFoundException)
from /Users/Dave/.rvm/gems/ruby-1.9.3-p194/bin/rails:19:in `<main>'
from /Users/Dave/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/Dave/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
I have tried uninstalling 3.2.6 and reinstalling but the result is the same. Any help would on this would be great.
UPDATE: I was able to solve this problem by uninstalling both 3.2.6 and 3.0.3 and then reinstalling 3.2.6. Not sure why this worked but it does. At some point I need to install 3.0.3 can these versions not co-exist?
After spending some time looking at gemsets that was definitely the solution to this problem. I set up RVM and installed two versions of Ruby. Then I setup gemsets for each version that had the version of rails I needed to write code for the book I was working through and the web server I am using.

Error while running rails on windows 7

I am trying to set my machine up so I can follow this tutorial: the intro to rails screen-cast i wish i had.
I keep running into issues, most recently the following:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/ansi-1.4.1/lib/ansi/code.rb:5:in `require':
no such file to load -- Win32/Console/ANSI (LoadError)
This occurs when ever I run rails g. (I would like to see if my r spec generator has been added.)
Environment details: Windows 7, ruby 1.9.2p290, rails 3.1.1, rubygems 1.8.15
After you installed "gem install win32console", can you add this gem into your Gemfile file and try to run bundle install again?
Gemfile
gem "win32console", "~> 1.3.0"
RailsInstaller may be your best bet if you're looking for an integrated Windows Rails experience.
It's up-to-date (-ish, doesn't use Ruby 1.9.3) with:
Ruby 1.9.2-p290
Rails 3.1.1
Git 1.7.6
and other useful bits.

Rails isn't recognizing Rails gem

I was working on a project just fine, logged off for the night and the next morning when I tried to start again I was getting this error:
Missing the Rails 2.3.12 gem. Please `gem install -v=2.3.12 rails`,
update your RAILS_GEM_VERSION setting in config/environment.rb
for the Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.
I did a gem list and it's definitely installed:
rails (3.1.0, 2.3.14, 2.3.12, 2.3.8)
I also made sure that 2.3.12 was the required Gem in the environment.rb:
RAILS_GEM_VERSION = '2.3.12' unless defined? RAILS_GEM_VERSION
Before I logged off I deployed my changes to demo, which was working fine, and when I checked it the next morning I was getting the same error message.
I'm still pretty new to RoR so I am not sure how to trouble shoot this.
I had this problem before and it was because I was defaulting to the system version of ruby. Run "ruby -v" in console and make sure you are using the version you want to. If you are not run this in the console:
$ rvm use "x"
Where "x" is the version of ruby you want to use.
Also, make sure your gemsets are in order. You can create and start using a new gemset by running this in the console ("xxx" = what you want to call your gemset):
$ rvm gemset create xxx
$ rvm gemset use xxx
After creating (and switching to) the gemset you can try reinstalling rails. Creating a new gemset means that there are no gems associated with whatever project you are working on anymore. So you will need to reinstall all your other gems too. Should be easy with a "bundle install"
Hope this helps.

How can I create previous version rails in rails 3?

I've just upgraded my rails version to rails 3.0.
But suddenly I need a new rails app with old version of rails.
I know the new version of rails change command line usage with rails new.
How can I create an old version of Rails in this new Rails 3 environment?
Use the following command:
rails _2.3.5_ new APP_NAME
This will create a rails project with version 2.3.5
Leonid Shevtsov provided instructions for how to do this here.
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Runbundle install
Run bundle exec rails . to create an app in the current path
You don't even need rvm to do this.
If you need to switch back and forth, I would recommend using RVM. You can install different versions of Ruby and each can have its own set of gems. I use my system installed ruby (1.8.6?) on my Mac for Rails 2 dev, and then I installed Ruby 1.9.2 with RVM for my Rails 3 dev. Its as simple as doing this after you have RVM installed:
#install and use 1.9.2 for Rails 3
rvm install 1.9.2
rvm 1.9.2
rails new whatever
#switch back to system installed ruby for Rails 2
rvm system
rails whatever

Resources