Join Kevin Skoglund for an in-depth discussion in this video Ruby, part of Ruby on Rails 3 Essential Training.
In this movie, we will make sure that you have the correct version of Ruby and if not, I'll help you to get it installed. Ruby on Rails 3 is going to require that we have Ruby 1.8.7 or greater. We can also use Ruby 1.9, but you don't want to use 1.9.1 because there were few bugs in it. But 1.9.2, which just came out recently, and anything after that are fine. The most important thing is that we use 1.8.7 or later. Now, Windows does not include Ruby so unless you have installed it previously, you are going to need to install it now. In order to install it, we'll go to the Ruby web site.
That's www.ruby-lang.org, and that's going to be the best place to find out current information about Ruby, what the latest version is, and how to download it. Right now, if we go there, the recommended way to install it is going to be using the RubyInstaller. That's maintained at www.rubyinstaller.org. So that's where, we'll end up going. But we want to go to the Ruby Lang web site first, just to make sure that there's not some new information that's come out in the meantime. Let's go there now. So, here I am inside Firefox, at www.ruby-lang.org and that will take us to a page that has some basic information about Ruby and what's going on.
What we want is this Downloads link. There is also one here for download but we will click downloads here and it will take us to a page where we can download it for all platforms. We want to scroll down until we find Ruby on Windows. That's going to be for us. It goes on to tell you, well there is a several ways you can install it, here's a bunch of different installers that you can use, but really what's going to be the most convenient and best, if you don't know that you need something more advanced, is this Ruby Installer. So that's what we are going to use. So, assuming that's still true and that's the advice they give you, we will click on that, and it will take us to the RubyInstaller web site.
From here, we can click on Download and we get a choice of several Ruby installers, version 1.9.2, 1.9.1, 1.8.7, and 1.8.6. You remember from introduction that I said, we want to use something 1.8.7 or later. So that means we don't want to use this one and 1.9.1 had a few bugs in it so we want to stay away from that one, but 1.8.7 or 1.9.2 or if that has since changed to be 1.9.3 or anything else, those later versions. So, which one to choose? Well, 1.9.2 is going to be faster.
Will you notice the difference in speed between 1.9.2 and 1.8.7? Maybe not. I mean, we're talking about a quarter of a second here a half of a second there. Once we actually installed this in our production environment, well then we would definitely notice, because we would have potentially thousands of people all coming to our web application at once. But when we are just doing simple development, you're probably not going to notice a-half-second difference here and there. 1.8.7 has been around a long time. It's very well tested. So that's something to recommend for it. Now for me, I probably would just go ahead and go with 1.9.2. And if I ever have any problem, I can always go back and use 1.8.7 instead, but why not go ahead and use the latest and greatest version.
On the Mac side, we're going to be using 1.8.7, because at least for the moment, that's what comes preinstalled with the Mac. But the difference in the language between 1.8 and 1.9 is can be very slight, especially at the low level that we are going to be using at an introductory session. There are lots of new features at a very high-end user level that are in 1.9 that we don't have in 1.8. But we are not going to be using those features anyway. So, for the most part, the main difference that you'll notice is 1.9 is faster. So, let's go ahead and download 1.9. So, it says where do you want to install that. Let's go ahead and say, yes let's save that.
It will save it to my Downloads folder. There we are. I can close up these windows in Firefox and let's just open a new window here on my desktop, and let's go into Kevin Skoglund, and into Downloads, and that's where we will find that file. So, there is the Ruby installer right here. All we have to do is double-click on that file, we will get some Windows Security warnings if you haven't turned those off before, and we will say yes, we do want to run this file. We get a simple installer. We just want to follow through and accept most of the steps here. Yes, I accept the user license.
Where do we want to install it? By default, it will install it at the root of your C drive, in a folder called Ruby 192. Some people install it as just simply Ruby. I think Ruby 192 is a good way for you to know and make sure that you have the right one. Do you want to add it to your path? You want to say yes, I do want to make sure that those executables are in my path, and do we want associate .rb and .rbw files with the installation. I would say yes to that as well. That way that .rb files are linked with Ruby. Let's say Install. Okay, now that we are done, we can just click Finish.
We can close this window up. Now, Ruby is installed. This is a program that will sit in the background, waiting for us to call on it, and the way that we activate it and use it is from the Command Prompt. So, we will open a Command Prompt window, we can type ruby -v, and that will be for version. It will tell us the version of Ruby that we have installed. It also lets us know that Ruby is installed. So, there we can check and say 1.9.2, patch zero. Now we can actually use Ruby with a couple of simple tests. We have ruby -e.
And that says execute this bit of Ruby code that I put in quotes, and I am just going to use "puts 100" inside quotes, and it will output 100. So that's all it did. It's very simple. It just says, "Hey! Ruby, execute this bit of Ruby code." So we know Ruby now does work. We also when we installed Ruby, we get irb, which is interactive Ruby, and that's a shell that allows us to interact with Ruby. It's like a calculator. Now, we are inside this Ruby shell. Everything that we type gets evaluated by Ruby. So we can say puts 1 + 1 in and there we go. It outputs 2.
When we want to leave this interactive Ruby shell, we can type quit. So, we know the Ruby is now installed. We know we have irb there, so we can drop in and use it anytime we want. Now we're ready to move on and take a look at installing RubyGems.
- Understanding MVC (Model View Controller ) architecture
- Routing browser requests through the framework
- Responding to requests with dynamic content
- Defining associations and database relationships
- Creating, reading, updating and deleting records
- Working with forms
- Validating form data
- Reviewing built-in security features
- Authenticating users and managing user access
- Debugging and error handling
Skill Level Beginner
1. What Is Ruby on Rails?
2. Installing Ruby on Rails on a Mac
3. Installing Ruby on Rails on a Windows Machine
4. Getting Started
5. Controllers, Views, and Dynamic Content
6. Databases and Migrations
7. Models, ActiveRecord, and ActiveRelation
9. Controllers and CRUD
10. Layouts, Partials, and View Helpers
12. Data Validation
13. User Authentication
14. Improving the Simple CMS
15. Debugging and Error Handling
16. Introducing More Advanced Topics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.