Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

What is the difference between the different versions of rails? How do I change my version of rails installed.

Apologies for the long winded questions but I would really appreciate it if someone with experiance with ruby on rails could help me out. Broadly I tried to group my questions into 3 parts. Sorry I know Part 3 is quite a few qestions, but I felt they were connected so I left them together. Thanks for your help in advance.

So I was doing the ruby on rails app ODOT tutorial when jason said that if I'm using rails 4.1 then some of the code may not work, as the tutorials are done in 4.0.1 version of rails.

1) Should I change it to 4.0.1 to complete the tutorial. If so How do I change my rails version from 4.1.4 to 4.0.1?

I'm using a windows computer and I installed the RoR environment using bitnami which gave me rails version 4.1.4.

Going off of the forum discussion I think that to get version 4.0.1 I would do

'gem install rails -v 4.0.1'

and then to create the blank rails app for ODOT I would do

'rails 4.0.1 new odot'

2)Is that correct or do I need to install anything before I run 'gem install rails -v 4.0.1'?

3) Since the code varies somewhat for the different versions of rails how will I learn a cohesive version of the language? Since the older Ruby on rails project treebook uses a different version of rails does it mean that I can't learn those tutorials? If I can still do those tutorials on a current version of railsHow would I do that? Does this mean that everytime that a new version of railsis released I have to go relearn it?

I'm a total newbie at rails an d programming ingeneral so any and all help is appreciated.Thanks again for your help

2 Answers

I will try to answer some of your questions.

You can install different versions of rails using the gem install rails -v 4.0.1 command, just as you wrote. When you do, from now on you can use that version for generating new applications that would use specific versions, the proper command is rails _4.0.1_ new odot (notice the underscores). You can try upgrading and downgrading Rails version in your project's gemfile and then running bundle update, but this might not be enough and some additional manual work could be required.

Rails is not a language - it's a framework that uses Ruby language. Ruby does not change that much from version to version, although differences are noticeable between major releases, like between 1.9 and 2.0. But Rails as a framework changes quite often and sometimes those differences are big (like the introduction of Strong Parameters by default in Rails 4, which makes it impossible to follow treebook videos with Rails above v3.2).

You have to learn to keep up with changes and adapt if you want to be a developer. You should learn both v3 and v4 (so go through ODOT and treebook apps), because in the future you might be asked to work with an older app that someone else wrote or even upgrade an app from older version of Rails to a newer one, so it would be good to know the differences and how things are done in those praticular versions. You will get used to it and it's not as crazy as you might think, Rails is quite established today, so changes don't tend to be that dramatic. You want crazy? I hear it's hard to keep up with Node.js and other hot, new JS frameworks, because they change a lot ;).

You can do both ODOT and treebook, just make sure you're using the proper version of Rails while generating the app or use pre-generated virtual machines from treehouse that have all the proper versions installed for each project.

Also, my personal comment: Windows is not the best choice for Rails development. I tried this for a few months, but it was painful sometimes. In the long run you should consider a Linux or Mac machine, or at least a virtual machine with Linux on your Windows.

Hey thanks for your reply I really appreciate it.Just some follow up questions.

when I install rails v4.0.1 (while I already have v4.1.4 installed) will that override the the version that I have installed? Or will it be like there are 2 seperate versions of rails installed (v4.0.1 and v4.1.4, where v4.1.4 would be the dominant one) and when I install v4.0.1 it's there but to use it I have to do 'rails_4.0.1_new odot'?

Going by that same logic just doing 'rails new odot' would mean I was using v4.1.4 of rails? Is that correct?

Also my ruby version is 2.0.0 while the treebook project says that it uses 1.9.3 for ruby will that be a problem for me? If so How do I get around it.

How do I learn to compensate for the differences bwtween the versions so that using ruby 2.0 and rails 4.0.1 I can make somethings similar to treebook? I guess what I'm trying to say is how do I bridge that gap in knowledge (and also learn about the changes that occur from using different versions of ruby and rails) so that what I learn in the tree book project will be applicable to all the other projects I do as a rails developer? I hope what I'm asking makes sense to you.

Thanks again for your help.

P.S I was wondering if you could explain to me a little bit about virtual machines.How did the experience of doing development on window lack for you?

I think you'd have to experiment, because I'm no sure how this would work under Windows (I use Linux with Ruby Version Manager, so it's a completely different situation). Install another version of Rails and then generate a new app normally (without specifying any version) and then see the Gemfile - it will show the version of Rails used.

Treebook should work fine with Ruby 2.0.0 and you would need some additional software to have different concurrent installations of Ruby running (in Windows that software is Pik, no idea how t use it).

The only way to learn those differences is by trial and error I'm afraid. Most people on Treehouse learn it the hard and frustrating way - by doing Treebook not knowing that there are differences and getting tons of errors...the most important one is Strong Parameters, which become more complex with Devise.

As for the virtual machines - Treehouse has videos about setting up a development environment, including videos on how to use their virtual machines. I never used them, so I can't really help you there, you need to try for yourself. Personally I use VMWare Player with Ubuntu, but there are no videos for that on Treehouse.

Ruby and Rails under Windows work slower, Windows Command Line does not support most commands that are used in Linux/Mac console (so lots of manual work, even if you use emulators such as CMDER), no access to nice tools like RVM, errors that are only seen only in Windows and less helpful advice online because most developers work in Linux and Mac. These are the major problems.