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 Ruby Gems Gems In Depth The Gem Command

3 Answers

Kevin Korte
Kevin Korte
28,149 Points

Run bundle update, it'll update to the most recent version within any version restriction you impose as the developer.

Alphonse Cuccurullo
Alphonse Cuccurullo
2,513 Points

Oh ok, thank you for a response man i am new at all this never heard of gem's but was familiar with the language. Is bundle a rail's framework? or is it a framework specifically to handle just gem's?

Kevin Korte
Kevin Korte
28,149 Points

Bundler is a gem itself.

https://rubygems.org/gems/bundler

Gems are just little packages of code that do something. It's basically modular attachments to your application. Like legos. When you add a gem to your gemfile, and run bundle install you know magically get all the features and functions that gem provides. Good gems will have clear documentation so you know what to do with it.

Bundle's job is to manage other gems. If gives you options like locking in versions, so say you want to be able to update a gem if it get's patched, but not update it if it's a app breaking change (say going from V2 to V3), bundle can help manage that for you.

For instance, if you had a gem that was 2.3.7, and the dev released 2.3.8, that should be safe to update to, as that's usually a non-breaking patch. bundle update if set up correctly in your gemfile would update that gem. But let's say you didn't want to go V3 yet, and all of a sudden that gem goes to 3.0.1, well bundle update wouldn't update, if configured.

If an update did break your app, you could lock in a very specific version, you could tell bundler to only use version 2.3.7, and it would.

Does that help?

Alphonse Cuccurullo
Alphonse Cuccurullo
2,513 Points

Yes very much thank you kevin. one last question an im out of your hair. So in other word's gems are piece of functionality that i could use for my program's if needed. So bundler is ment to update gem's a an categorize them? Is that its only purpose? Is bundler used in combination with rail?

Kevin Korte
Kevin Korte
28,149 Points

Correct, bundler is used in combination with rails. Rails is technically a gem too. Bundler can be used in Rails, Sinatra, RubyGems, Rubymotion. You'll see this word used a lot, as there are numerous programs for different langagues that do this same stuff.

And so bundler's job is to download, install, update, and otherwise manage other gems. Bundler would even manage the rails gem.

Here is a good source to look for gems https://rubygems.org/

You're right, gems add functionality. Here is a super popular gem, but a bit more complex. The devise gem gives your ruby app a full user account setup out of the box. It's highly configurable and very popular https://github.com/plataformatec/devise

One that is a little bit easier, here is a gem to create easy pagination. Just about every website needs pagination at some point. Look how easy bundler makes installing this gem, and how easy it is to paginate after this gem is install. https://github.com/mislav/will_paginate

Another gem I like is called friendly_id. Again, something most apps will want. Look how much funcatilty you get so quickly thanks to gems. https://github.com/norman/friendly_id.

Does that help ya?

Alphonse Cuccurullo
Alphonse Cuccurullo
2,513 Points

This does this is great. I am slowly getting the hang of it. There seem's to be a problem tho. I am trying to install bundler through the command promp but for some reason it say's this. "C:/ruby22/lib/ruby/gems/2.2.0/extension/x86-mingw32/2.2.0/json-1.8.3/gem_make.out an error occurred while installing json (1.8.3), and bundler cannot continue. Make sure that 'gem install json -v 1.8.3 succeeds before bundling."

So i don't get it to be honest with you. I already installed rails an ruby. i Set up my rails folder an stuff but don't see where the error is coming from. I know i need bundler because it really get's rid of alot of the dependency problem's. Please help