I have my current application in Ruby 1.9.3 and I want to migrate it to ruby 2.0. I have googled it but couldn't find any resource that clearly describes the steps required to upgrade to 2.0. Can anyone give me the stepwise guide for migrating from ruby 1.9 to 2.0? thanks in advance.
This is a detailed instruction:
install new ruby version
run all tests
fix all errors
profit
You need to follow the following steps:
Install new Ruby Version
Run bundle install (you may need to update some gems and rails)
Run tests . (If you have coverage of all of you application. If not run the whole application manually and fix the errors. Most of the errors would be syntax and other small issues.)
Your application is migrated.
Related
Trying to migrate application from Rails-1.1.2 to 2.0.0 to current version.
Basic problem is can't find documentation for it.
I think in Rails 1.1.2 they don't have command to update the application like bundle update rails or rails app:update.
Directly changing ruby version gives boot error.
The first thing you need to do is to upgrade your Rails app to version 1.2.6, which is documented here.
After that you can upgrade to Rails 2.0, which is documented here.
The Rails releases page might be a useful page for you to check out, since they hold the info on how to upgrade. Like you said, there's hardly any information on how to upgrade the older Rails versions, so the official releases page is your best bet.
I'd upgrade to each release individually, so from 1.1.2 to 1.2.0, then to 1.2.6. Then go to 2.0, 2.1, etc. Update your Ruby seperate from it.
You can't directly migrate rails-1.1.x to rails-2.0 due to till Rails 2.3 doesn't have built-in bundler support because it came out before Bundler and no Gemfile in rails also that not a good way to directly update the ruby.
Note: before migrate to any version make sure you have more than 70% test coverage.
Steps help to migrate
Change the rails version (rails 1.1.x to rails 2.0) manually (means in vendor folder).
Run the test case and fix the failing syntax in your code (If any)
Then migrate rails 2.0 to rails 2.higher version (make sure higher than rails 2.3)
Again Run the test case and fix the failing syntax in your code (If any)
Then migrate rails 2.x to rails 3 pre version
Now you can add Gemfile put all gems into that upgrade your bundler gem.
Now you can migrate the ruby version as well.
Again Run the test case and fix the failing syntax in your code (If any)
Then migrate rails 3.0-pre to rails 3.higher version
Again Run the test case and fix the failing syntax in your code (If any)
Then migrate rails 3.x to rails 4 pre version
Now you can migrate the ruby version as well.
This is very long successful process for rails migration if your rails version older that 3.0.
There is one more way to achieve that. If you just want a Gemfile, rather than Bundler integration with Rails, you can create one easily enough.
gem install bundler
bundle init
Then follow below Guide to The Rails Command Line may help you, especially the section that covers rake gems:install.
https://guides.rubyonrails.org/v2.3.11/command_line.html#rake-is-ruby-make
I hope that help you.
Before looking at starting to upgrade an app from such an old version of Rails, I'd suggest reviewing how complicated it is and questioning if it would actually be quicker to build from scratch in the most recent version rather than go through so many upgrades.
I received a ruby on rails application that was written three years ago
(Rails 4.2.1)
I need to update everything to current version of ruby, rails, rvm, bundler, rbenv, gems, etc...
Please help on process to achieving the update and the app to run not only locally but live.
To check what your ruby in now
$Ruby -v
Update it to ruby version 2.3.7
$rvm list known
$rvm install 2.3.7
$rvm use 2.3.7 --default
$gem install bundler
Let me know if does that help!
Hey dude upgrate from a very old to newest versions requires a lot of patient and skills. I found an article that might help you and also helped me before. I hope it can help you. Let me know if you have any more doubts
Upgrade ruby on rails project
Start a new Rails app with the latest Ruby, and use Test Driven Development to port the old app over, line by line.
Write a test that fails, copy a line out of the old app, pass the test, integrate & deploy, and repeat until all the features are installed - with tests.
TDD is where you write a test that fails, run it and make sure it fails for a correct, predictable reason, and only then add the production code that passes the test. Only integrate if all the tests pass. Learn more about TDD at its original web page: wiki.c2.com/?TestDrivenDevelopment . Learn to TDD in Rails by reading its flagship book, /Agile Web Development with Rails/.
In my system I have rails 4.2.5
and ruby 2.2.3.
how can I update to rails 5.0.0.beta version.
Thank you.
The upgrade instructions for the current beta are available here.
You need to have a test suite with good coverage before you begin. Run rake rails:update to update your configs. You also need to follow the instructions on the upgrade page, which include changing class names to the ones that are currently in use.
I have updated rails and have rails -v and it says 3.0.5. (which is good) when i open my old programs, will it still always use 3.0.4 as that is what was used?
And ..
when i create new one will it use 3.0.5
I have done this as i'm a newbie and having problems with tutorials from the rails by example book michael hartl and wondering if it is the version that is giving the problems.
Thanks for any help..
In Rails 3 Bundler was added to handle gem dependencies. Within each application a Gemfile exists that specifies the version of Rails to use. If you want to update an application change the version in your Gemfile and run bundle install.
I'm learning Ruby on Rails with the AWDR book and have had to be specific about which version of Rails and Ruby that I am running on my local machine. I have just discovered that I need to roll back from ruby 1.8.7 to ruby 1.8.6 here. I also needed to roll back Rails to support the scaffold method so I could start the tutorial easily.
My question is: When I start contracting, developing and deploying projects in the real world, how am I going to manage all these different versions?
It looks to me like Rail's low tolerance for legacy code negates its ease of use philosophy! But I'm sure I'll grow to appreciate RoR.
As for Rails, What you can do is freezing your version, for example:
Make sure to install the proper Rails version, suppose you want version 2.2.2 : gem install rails v=2.2.2
Freeze and pack Rails with the project itself : rake rails:freeze:edge RELEASE=2.2.2
Now you will find Rails packed inside the vendor folder of your project, so you don't have to install Rails on the deploying machine.
And for Ruby, I like Ruby Version Manager(RVM), the easiest way to manage Ruby versions.
RubyGems is Ruby's package manager. You can install as many versions of gems (packages) as you want. You can install the latest by running sudo gem install rails (at the moment it will install 2.3.5). If you need 2.2.2, specify that with the -v or --version option: sudo gem install rails --version 2.2.2. Rails also installs a binary (yes, I know it's not really a binary file), rails, which generates a project. Because you have several versions of the gem, you need to control which binary gets called. When you install the rails gem, RubyGems puts a file in it's bin/ dir, which is a "link" to the real rails binary. That is the one you "call" when you say rails on the command line. However, all of the rubygems "link" binaries accept a parameter of it's own, which is what version you want to use. You would use the 2.2.2 rails binary like this:
rails _2.2.2_ my_project
I think the default is to use the most recent version, so if you want to use the most recent version, do this:
rails myproject
However, I see that you use 2.2.2 to get access to the scaffold method. I would strongly suggest you not to use that method, there's a reason for removing it. The scaffold method hides code, and makes customization hard. Instead, use the scaffold generator:
./script/generate scaffold --help
Good luck on your future rails adventures!
The latest version of Agile Web is written for 2.2.2 I believe. For this basic app they walk you through I'm very certain it should work with 2.3.x
The answer to the question for how you keep up is that you update your apps as needed and read the api and Changleogs to find out what has changed and fix the stuff that upgrades break. A great way to help with this is having a good test suite with good test coverage.