DEV Community

loading...

What the h*ck is a gem?

mariel
Dev. I love dogs, cookies, and learning new things.
・1 min read

What is a gem?

Before studying Ruby, I thought gems were the sparkly things you put in jewelry.

BUT NOPE.

Well yes, but also nope.

In Ruby, "gems" are third-party libraries. That's it. But! they have a cute name because Ruby is - wait for it - a gemstone.

What do I do with them?

Gems can be incredibly helpful when developing your apps, taking care of work you'd otherwise need to do manually. Gems exist to help you work with a database, test your code, run a local server, and salt and hash passwords.

How do I find them?

Your gems are going to come from RubyGems.org. You'll want to download the RubyGems package manager, which will then allow you to do some handy things from the command line. Most frequently, you'll be using

gem install 
Enter fullscreen mode Exit fullscreen mode

to install specific gems to get going. A few other commands are listed on the Wiki page.

Where do I put them?

Gems are stored in a "Gemfile" - this file specifies the name and version of each gem you'll be using, and you can separate them into groups for production, development, and testing. This is helpful when you're doing something in development (e.g. using SQLite3) that won't work in production (e.g. Heroku won't let you use SQLite). A particularly helpful gem is Bundler - it lets you install your gems easily and keeps up with the dependencies for you.

And that's your 30 second rundown on Ruby gems.

Discussion (2)

Collapse
aminnairi profile image
Amin

You had me at

Well yes, but also nope.

Haha! Great article. I know only a little bit about ruby and your article was simple, concise and clear. Thanks!

Collapse
mariel profile image
mariel Author

Thank you! That's exactly what I go for when I write!