Join Kevin Skoglund for an in-depth discussion in this video RubyGems, part of Ruby on Rails 3 Essential Training.
Now that we have Ruby installed, we're ready to install RubyGems. RubyGems is another package manager. We've already installed two. We've installed HomeBrew to manage open source apps and we've installed Rbenv to manage our Ruby versions. Now we've got another that will manage our Ruby helper libraries and plugins that our Ruby on Rails application is going to use. A single RubyGem, or just called a gem for short, is simply Ruby code that's been packaged up for easy distribution using the package manager.
Rails makes extensive use of RubyGems. In fact, as you'll see, Rails is itself a gem. Let's take a look. We'll start by going into the terminal and then the command line, we'll just type: gem -v, to find if you have ruby gems installed and if so, what version you have. Mine tells me that I have version 2.0.3. If I type: which gem, it'll give me a clue about how that got installed. You can see that it's in this RBN folder, inside shims. And that lets me know that during the process of installing RBN and Ruby it also installed RubyGems at the same time.
Now if you didn't install Ruby using RBN, maybe Apple had already installed it for you. Or you used an alternative method like RVM. Then you may see a different location here. And maybe even a different version. That's okay. We can use Ruby gems by just typing gem list. We don't type Ruby in front of it. Just type gem, gem list. And it'll come up and show you the gems that are currently installed. You can see that I don't have very many. Next, let's update our copy of Ruby gems to make sure that we have the latest version. You can do that using gem update and then dash, dash system, that will go out to the Ruby gems server.
Look and see if you have the latest version and update it if necessary. In my case, I do have the newest version latest of the time I am recording this. So, it comes up and says latest version currently installed aborting. It doesn't actually do any update. Viewers may go ahead and proceed updated, it's fine, and then gem dash v will show you what the version that it actually resulted in would be. Don't worry if your version is newer than what I have. You just want to make sure you have the newest version. I also want to just show you that you can use gem --help, and that will give you more information about how you can go about using RubyGems.
Well, that's a good place to look for help and guidance. I also want to show you the RubyGems website. All of the different gems that are published get put here on RubyGems.org. This is the central repository, the place where everyone can look for these gems. And you can see that at the moment there are close to 60,000 gems that are available up here. And it even gives you the number of downloads, this huge number of downloads from people installing these. So you can see this is the clearing house for all of these little libraries that our different application is going to use.
You can search for different gems by clicking up here in the search bar. And let's look for, will paginate. And it comes up, and it offers me, will_paginate. This is a very popular pagination gem that allows you to have page one, page two, page three, and so on, of your results. So that's way you can find them, and then you can see that it gives you the installation instructions that you would need here. We'll talk about Gem files a little later on. Once you put in your Gem file, and then there's also, where you can browse the source code, in a lot of cases, you can go in and look at documentation and things like that as well, to find out how to use these gems.
Now that we have ruby gems installed it will be really easy for us to install not just rails, but also these other libraries that we would use while we're developing with rails. Its going to become a very essential tool and you'll be glad that you have it. Now let's move on to installing rails.
- 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?
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.