Upgrade timing for Rails on new OS X? - ruby-on-rails

Looks like Apple just released OS X 10.9 Mavericks, and I'm thinking about upgrading from 10.8 Mountain Lion. I'm running Rails 3.2.15 with Ruby 1.9.3.
I have several things to potentially upgrade, and they're not necessarily related:
OS X 10.8 --> 10.9
Rails 3.2 --> 4.0
Ruby 1.9.3 --> 2.0
What is the timing cycle usually like for new gems, etc to cooperate nicely with OS X? Is it better to wait a week, or a month, or several months? Or would it be pretty seamless to upgrade OS X and then upgrade Ruby + Rails?

There are not a whole lot of differences between Ruby 1.9.3 and Ruby 2.0, though I've had one gem trip me up in the upgrade. If you find that you need to use 1.9.3 still you can install brew (http://brew.sh/) and RVM (http://rvm.io/) to help you manage multiple Ruby versions. Please note you'll have to install XCode and/or it's commandline tools to compile software.
The biggest change I have found with Rails 4.0 is how it handles whitelisting of attributes to be used in models. Instead of using attr_accessible in your model, use strong parameters in the controller. You can see how to use them in this answer.
As far as how they handle on the new OS, it may still be a little too early to say if there is any wonkiness involved. I usually go a couple of months before upgrading just of that reason.

Related

How to find out what Ruby version a project has used + Github

I cloned one of my 3years old project from Github to resurrect, however I'm getting bunch of migrations, gem, etc errors. Googling gives me tips about possibly using wrong ruby version.
I want to assign the specific rbenv local rubyver but I don't know which one I used and I can't find it in any settings?
Any idea how I can find what Ruby version is this project using?
There's a few places this might be annotated:
A .ruby-version file, though these are often ignored to avoid friction between developers with slightly different versions. This is what rbenv uses, as well as other tools like RVM.
The Gemfile can have a ruby version lock in it, though this is usually a minimum requirement, like >= 2.3.0.
The README if the developer is kind.
Otherwise, there's no real way to know.
It's worth noting that Ruby 2.0, 2.4 and 3.0 are often the biggest upgrade hurdles, so it's worth trying with the latest version you can get away with, like 2.7.2 if practical, 3.0.0 if possible.

Uninstalling Ruby to go to an older version

I'm trying to learn Ruby On Rails, and found I can't really use Ruby 2.2.2 because Nokogiri doesn't support it on Windows yet.
How do I roll back Ruby to an older version so I can develop on an older framework while I wait for Nokogiri to come up with a product for Windows and Ruby 2.2.2?
What is the best way to uninstall it so I don't have bits hanging around that might cause issues?
This is in response to my question: "Error installing "nokogiri" in a Ruby on Rails application?"
Linux users: please remember that not everyone is interested in switching their OS, running 2 machines, trying to figure out dual boot, or dealing with virtual machines dragging down a host. While Linux is a great environment for software development, people, like the OP, just looking to try their hand at something (like ruby/rails) should not immediately be told to switch to something completely unfamiliar which might not even adequately support their normal day to day activities.
Since I am not a believer in making anyone leave an environment they are comfortable with (especially since you stated "learning". Why would you want to make an additional investment just to try something out?) and because I did not want my comment to get over looked as it will help with your issue, I have decided to post this as an "answer".
Mac and Other *nix based OS's have the ability to install rvm (Yes I know there are more but rvm is my personal choice and a community favorite) which allows you to manage different versions of ruby on the same OS.
While rvm is not available for Windows there is a small application called uru which will get you as close from a windows standpoint.
Installing a version manager means that you do not need to uninstall or rollback anything you can simply install a new/old ruby version side by side the current versions you have and switch between them fairly easily from command line.
While uru does not have all the fancy features that other applications like rvm possess (by design). It contains the important ones (primarily in your case switching ruby versions). The CLI is very simple and straight forward. Examples of uru Usage
Also: Please note I work in an Windows centric Office and have developed more than a few fully functional rails applications on a windows machine. Yes there are some headaches when dealing with native extensions and know that you will always be slightly behind the leading edge for ruby and rails but it is completely possible and feasible to build enterprise level web applications completely in a Windows environment without ever installing Linux at all. (Note I do use dedicated Linux machines for non development web servers)
Go to your control panel and find the ruby or rails installer. Uninstall it. Go to your file explorer and make sure the folder is gone.
Now go to http://rubyinstaller.org/downloads/ and pick an older version. Follow that process just like the first time you installed ruby. Then go get nokogiri and whatever other gems you like and enjoy.
I had the exact same issue when trying to some gems(stanford core nlp & treat) to work that relied on JVM that was 32bit instead of 64 like the version of ruby I was running so I reverted to 1.9.3.
I'm also in the avoiding moving to OSX or linux camp so I feel your pain man.
Let me know if this works and good luck!

Should I be worried about the RVM warning about Ruby 1.8.7?

To what degree should I be worried about the following warning that is displayed after installing Ruby 1.8.7-head via RVM:
Please be aware that you just installed a ruby that requires 2 patches
just to be compiled on up to date linux system. This may have known
and unaccounted for security vulnerabilities.
Yes. Someone thought it was important enough to write that for people to read. Ruby is a fast moving language and 1.8.7 is all but dead. I would suggest 1.9.2 if you like something a little more slow moving, or 1.9.3 if you like living on the edge.
It depends on what you're using it for. We use rvm to build 1.8.7-series rubies so that we can develop on a recent OS but deploy conservatively. For instance, the ruby on Debian Squeeze is ruby-1.8.7-p302, and it's important to us to know that our code works there as written, no matter what OS we're individually developing on. In this case, I'd ignore that warning.
If you're using RVM to provide your production ruby, I'd pay more attention.
If you really need 1.8.7 but want a slightly more updated and optimized version you might want to check out REE http://www.rubyenterpriseedition.com/

What is the latest stable Rails version?

What is the latest stable version of rails? I want to install rails 3.1 but I see there is 3.1.3 now, what is the difference? What ruby version is it most compatible with?
I recommend to always check on GitHub via the "branches" menu what the latest version is on each branch.
You can see the latest version easily by checking the contents of the RAILS_VERSION file
https://github.com/rails/rails
You could also check RubyOnRails.org, but looking at the source code is the most reliable way.
If you already have a Rails App in production, I would highly recommend: don't just blindly take the latest version just because it just came out -- there were many cases in the past where a new version introduced incompatibilities or new bugs which were serious enough to have to wait for a fix before the features in the Rails release were really usable. I know a couple of people who have Production sites and still run 3.0.11 or lower, rather than 3.l.x
Again: check on GitHub under "Issues" which open Issues there are for a release, and/or google "Rails 3.y.z Problems" with the exact version number, so you get a feel of what problems could be introduced by upgrading to a new / the latest version.
On Wikipedia they have a list of historic release dates for the major Rails versions:
https://en.wikipedia.org/wiki/Ruby_on_Rails
The Rails version numbers have been explained reasonably well (Joseph Le Brech's answer), but the Ruby version numbers are slightly confusing and I could see why it's not really obvious what's going on there.
Joseph's explanation of Rails version number scheme is correct for Rails, but Ruby has a slightly different approach
1.9.3 is the most recent version of Ruby. Having said that, it was only released maybe a month ago, so it's possible there are breaking issues with certain gems. (Yes, there were breakages. Ruby in general will introduce breaking things between hotfix releases, and it's true here too)
1.9.2 is a more tried and true version of Ruby, having been out for at least 6 months now.
1.8.7 is the last version in the Ruby 1.8 line. Major language rework happened between 1.8 and 1.9, so some older gems may not have made the transition.
My recommendation: use Ruby 1.9.2 and Rails 3.1.3, unless you have really good excuses not to.
Ruby 1.9.2 is probably the safest bet for a Rails newbie, or green-field projects (projects without a lot of preexisting code). Rails 3.1 is an excellent version of Rails, which solves a lot of problems I had with the framework.
Rails 3.1 was released this fall, so old tutorials won't work, or will give odd errors. Try to look and read what version of Rails the book/tutorial/website/blog entry is talking about, before you dive in.
Latest stable release is always shown on the Ruby on Rails website's home page here http://rubyonrails.org/
To list all rails versions by gem:
gem list -ra rails | grep -G "^rails\ "
It's also helpful for cheeking what is the latest version for 4.x, 3.x and 2.x too.
According to rubygems, it's 3.1.3. Looks like you forgot a ..
major.minor.hotfix hotfixes will never change the behavior of an app unless you previously had a workaround for a bug implemented. Apps can easily be upgraded thru minor revisions, but it's usually not worth it and can be a distraction from getting features out of the way.
The latest release is 3.1.3. This is a minor release which has security and minor improvements.
The main version is 3.1, while minor upgrades are included in 3.1.x releases.
Anyway you should always use the latest one.
usually if you'll pull the latest rails gem, it's the stable one (unless once in history). although you can still use ruby 1.8.x version with the latest rails 3.x, it is more recommended to use 1.9.x.
anyway, everything you might need is in http://guides.rubyonrails.org and some nice people (including myself) are answering all bunch of questions in IRC on irc.freenode.net (#rubyonrails and #railsbridge)
good luck
The latest release is 6.0. it was released on August 16, 2019, making Webpack default, adding mailbox routing. Rails 5.2 is still maintained.

Which version of Ruby should I be using now (Jan 2010)?

I have vanilla Mac OS X Leopard which comes with 1.8.6.
I am new to RoR so will be following tutorials on the net. Am I likely to find problems following them when using later versions of Ruby?
I am currently looking at this one which mentions 1.8.6 and 1.8.7 - http://www.railstutorial.org/book
RoR tutorials will be fine on both, but if you're learning Ruby you should learn 1.9. 1.8.6 won't be supported in Rails 3, so I'd say go 1.8.7 or 1.9. I also recommend RVM for switching between Ruby versions.
The 1.8.x series (mostly 1.8.6) is still very much in widespread use and likely to remain that way for at least a year or so; 1.9 is slowly being transitioned to. Although there are some major differences between the two, for the most part everything you can do in 1.8 you can also do in 1.9.
Many of the trickier bits, like blocks and lambdas, get a bit of a makeover, but otherwise tutorials for 1.8 will still apply to 1.9 for the most part. You're likely to run into issues if you use gems and libraries from 1.8 in 1.9, however.
I believe Rails 2.3.5 is fully compatible with Ruby 1.9. The problem is not usually of Rails itself, but from other gems and plugins that might be outdated. However again try it, most likely you won't face problems.
Anyway, I highly recommend Ruby Version Manager(RVM) for trying several versions of Ruby.
I'll second the 1.9 recommendation. I'm kicking myself for not settling on 1.9 a year ago.
It's much more future-proof at this point. Targetting 1.8 is about like targeting Windows Vista at this point.

Resources