How to upgrade from Rails 5.1 to Rails 6.0? - ruby-on-rails

The title sums it up pretty much.
I want to do it via the console using the `bundler. There are several changes on the way rails has handled things such as the frontend. More details over here.
Will I have to rewrite frontend of my app again? Will it be enough to just update the bins and executables manually? Or run $ rails app:update to overwrite old stuff.

Well, it may have been a joke back when you originally posted this question, but Rails 6.0.0 is now a reality! Released Aug. 15, 2019. I would recommend running gem update rails as a first try, but "updating" to Rails 6 was not so easy for my Windows 10 system.
If you used railsinstaller.org to install Rails previously, you will not be able to install Rails 6 with it - or update - at the time of this writing. In order to update to Rails 6 you must be running ruby 2.4.4 or greater, but railsinstaller.org is limited to ruby 2.3 max. Check your version with ruby -v. I used this tutorial to do a fresh install of Ruby 2.6 and Rails 6 while updating gem to 3.0.
I would recommend installing everything fresh so you know where all of your dependencies are and how they work. It will also be much easier to update each individual component this way -- unless you opt to use tools like rvm, which by nature will be easier.
If you're having issues and want a fresh install of the latest Ruby and Rails, read the article I linked :) I only posted this answer because I know railsinstaller.org was recommended to a lot of people (like me) as an easy install method back when it was being maintained.

Latest version — Rails 5.1.5 released February 14, 2018 .
Rails 6 is NOT released !! And if it was the case bundler should make it clean

The post you linked is just a joke. Anyway, Rails 6 is under development (since January 30 I believe). Just wait.
https://github.com/rails/rails/blob/master/version.rb

Just run on your terminal:
gem update rails
That worked for me.

Related

How to upgrade big Ruby on Rails project from Rails version 4.2.2 to 6.0.2.2?

I have a huge rails web application with wide user base which runs on Rails 4.2.2 and Ruby 2.2.2 as of now. I simply want to upgrade the whole application to the latest version of Ruby i.e. 2.5.0 and Rails 6.0.2.2.
The reason for upgrade being I want to integrate a completely separate React.js frontend and a separate Rails backend. Other reasons for upgradation being deprecating older version of gems and rails.
I have tried researching a lot for this. I have also tried the : https://guides.rubyonrails.org/upgrading_ruby_on_rails.html guides. But everything out there is so vague and haphazard. I havent found any clear cut method until now following which I can upgrade my rails application smoothly.
Please help.
What i would recommend you to do is to upgrade to Rails 5.x.x first and than to 6.x.x you can use those guides and follow step by step:
https://www.ombulabs.com/blog/rails/upgrades/upgrade-rails-from-4-2-to-5-0.html
https://selleo.com/blog/how-to-upgrade-to-rails-6
I would recommend a progressive update for both Ruby and Rails. I would for example start by updating Ruby from 2.2.2 to 2.3, using the Release notes as guide of what things have changed:
https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released
Once that work (which would be easy to check if you have high test coverage), I would continue with Ruby 2.4 and so on.
Ruby minor releases (for example 2.2.2 to 2.2.3) shouldn't include breakable changes, so you can just go from 2.2.2 to 2.3, 2.4, 2.5 ...
Also, note that the last version Ruby is 2.7.1 and not 2.5.0. Another good reason to update your Ruby version is that it is not maintained any more and it does not receives security fixes. 2.5.8 is in security maintenance phase, which means that it won't be maintained anymore soon. You may want to update to at least Ruby 2.6.
Regarding Rails, you can find the release notes here: https://guides.rubyonrails.org/5_0_release_notes.html (just change the number in url to get the information of a different release).

Updating Ruby 2.2.3 to Current

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/.

first time user to Ruby on Rails program

i'm new user here. and this is my first question regarding Ruby on Rails. so, i wanted to ask what is the correct program version of Ruby on Rails, i have seen only 2.1 and 2.2.
i was looking for 5.0 to install and use it for first time. i chose RoR (nickname for Ruby on Rails) to create a website that can have many useful features like a site would do. but i'm at loss because i have no idea where i could find a RoR 5.0 or should i just install a older package of RoR to update to 5.0?
also, i have additional questions.
1: is RoR a program that can help you make website or blog, forum? or it's just a one in all package?
2: can you actually put together a section inside a site for news information/updates?
3: where do you find or make a code for mailing list which users can have a mail updates sent to their email?
these are my questions, you see i'm quite fond of a site that is run on RoR. so i'd like to try my hand on creating a site of my own, particularly one with a forum. like any kind of development, it's fun to learn. will you answer my questions and help me learn the program of Ruby on Rails?
Ruby is a programming language which has it's own version number. Rails is a library written in Ruby which has it's own version number as well.
The version of Ruby is not the same as the version of Rails. Rails 5.x requires Ruby version 2.2.2 or higher.
You can view the versions of each by using
$ ruby --version
$ rails --version
You can use the latest stable version of Ruby. – get it from here: https://www.ruby-lang.org/en/downloads/ (The current latest stable is 2.3.1)
To get the latest version of Rails, use the gem install command. (The current latest stable version is 5.0.0.1)
$ gem install rails

If i have newer ruby and clone older ruby project will i break project upon merge?

I can't seem to find this simple yes no question online so sorry for the super noob question!
I'm using an EC2 instance for my development and I set it up to have ruby 2.1.1 and rails 4.1. I have RVM, but don't actually have any other ruby versions.
I cloned my friends project and told him I would start helping him. His project is a ruby 2.0 and rails 4.0.4.
He's concerned that when I merge changes it will update the project to 2.1.1 and rails 4.1 and then it will crash on his computer (since he doesn't have 2.1.1 or rails 4.1)
I don't think this is the case, but I'm not 100% sure, so how valid are his concerns? I was under the assumption that as long as I don't use any functionality from rails 4.1 and 2.1.1 that isn't in 4.0.4 or 2.0.0 then there is no need to be concerned. Also, I assume when I cloned the project and make changes to it, it should stay in 4.0.4 and 2.0.0 versions. Is that true?
Thanks for any clarification!
The Rails version should be defined in Gemfile, so unless you change it, it will stay the same (and when you run bundle install the proper version will be installed if it's missing, so even on your computer you will not work on Rails 4.1, but on Rails 4.0.4).
With Ruby version it's a bit more complicated, because it can be defined in some file (like .rvmrc or .ruby-version), but does not have to. Still, if you don't change anything in project's configuration, neither Ruby nor Rails version will be changed.
If you are physically merging a 4.1 into the 4.0.4, then you will most likely encounter some issues. (I don't know the exact differences between those versions, but a full minor version up usually comes with new/changed goodies)
If you are just working on each app separately, then they would be isolated by their Gemfile. This is assuming the Gemfile.lock has been saved into the repo. Or the versions have been locked in the Gemfile itself.
Your Ruby version probably won't matter if you are running the bundle install fresh on your current version. Unless there are specific needs for a specific version.

Do I need to revert to an older version of Rails just to run a single legacy app (among other problems)?

I have an older Rails app that I need to run. But I have the latest version of Rails.
When I try to run this older app it says:
Missing the Rails 1.99.0 gem. Please
gem install -v=1.99.0 rails
But when I run the command: gem install -v=1.99.0 rails
ERROR: could not find gem rails
locally or in a repository
Not sure what to do next. Could someone help me understand what's happening here?
And my second question, related to this problem is: It seems silly that I need to revert to an older version of Rails just to run this one legacy app - there must be a better way of doing this?
AFAIK, v1.99.0 is sort of a v2.0 prerelease, so you could try installing v2.0.x, changing the RAILS_GEM_VERSION in config/environment.rb and runing rake rails:update.
If you think about it, it's not as silly as it might seem at first. You make an app using a fast evolving web framework as RoR. Your choices are: continue developing your app at aproximately the same pace the framework is evolving, or freeze the rails gem (and evertything else your app depends on, like gems, plugins) into your app in order to make it less fragile to expecting gem updates.
Regarding the second question: yes it is silly. Fortunately the Rails team spotted that silliness and at some point they gave us the ability to "freeze" the versions of Rails libraries required by an application (and also specific gem versions) into the vendor directory.
To freeze your version of Rails:
rake rails:freeze:gems
There's a good blog post from a while back describing this.
Unless you install and deploy RVM, your installation will roll back your system rails installation, which will impact your other projects. If you want to manually administrate your development environment this way, you can uninstall rails first, and then install the desired version of rails for the current project.
But try to install your rails gem instead with this syntax:
sudo gem install rails -v 1.99.0

Resources