Step-By-Step Guide to Building Your First Ruby Gem


Nowadays all the functionalities in Rails are built as Ruby gems. For example we can use devise gem for the authentication part of the application. It’s like a package or library that is written in Ruby programming language. Moreover it can be imported and used by others in their programs.

Step 1
Bundler is like a dependency management tool for Ruby, which is also used by Rails. We will use Bundler for the basic gem structure. It helps us to install the correct versions of the gem and forces us to use the same in the application. So the command for that is, gem bundler install
After bundling, we should specify the gem “name” that we are going to create i.e. Bundle gem “testgem” will create a repository shown below

ruby-gem - Step-By-Step Guide to Building Your First Ruby Gem
So in this we can see the basic gem structure. Under the lib folder, version file will be used to mention the version of the Gem. We can edit the version as per our convenience and release it that will be the version in Rubygems.

rubygem - Step-By-Step Guide to Building Your First Ruby Gem

Step 2
We will consider testgem.gemspec, with testgem as the name of the gem that we will create for sample. It will be used to set up the gem on rubgems, for e.g., name of the gem, summary, description, files that are required in this project, test files that are used to testing the files in the project etc.

ruby-gem-1 - Step-By-Step Guide to Building Your First Ruby Gem
Rake file: – This makes releasing the new versions of the gem, and also helps other developers to check the test cases if they are going to modify the particular gem.
After the rake, we should create a test folder and test cases for each segments will be included here in the app directory.

Step 3
Planning to make a rubygem, then we need to analyse the requirements what to build up and what all functionalities should be included in that.
While generating, we should create a sample.rb file inside lib folder and create own class with namespace because the other plugin has also the same classes then it will get conflict in the names. And require the sample.rb file in the testgem.rb file like reqiure “testgem/sample”.

Step 4
We have require “bundler/gem_tasks” in rake file so when we run rake release, it will release the gem to ruby gems and make it available. Push to git repository

RubyGems are commonly used in Applications
1) Rails – Rails is a ruby gem
2) Better Errors / Rails Footnotes – Debugging tools for Rails/Rack apps.
3) Resque / Delayed Job / Sidekiq – Used for creating background jobs, placing them on multiple queues, and processing them later.
4) Cancan / Devise – Authorization / Authentication Gems for Ruby on Rails.
5) Letter Opener – Test your emails within the browser itself.
6) Discourse – Discussion Forum.
7) Carrierwave / Paperclip – Classy solutions for file uploads for Rails.
8) Whenever – Cron jobs (scheduled tasks) in Ruby.
9) Thin / Unicorn / Puma – Web servers.

RailsCarma provide end to end Ruby on Rails Development services including, consulting, architecture, building, management and extension to companies around the globe. You can also hire Ruby on Rails developers with an easy to hire process. Contact us to know more.


How To Set Up A Rails Application On Main Domain With Passenger?

Upload your application to the server using either ftp/sftp or SSH or if you have your application under version control, checkout or clone your application to a folder in your home directory.

–Next, we need address apache/passenger about your application, this is done by setting a symbolic link from your public_html directory to your applications public directory. Here in the following example my application name is “myapp”.

For example, if your application is in myapp then you would issue the following commands in an SSH session: (Make sure there is nothing you need in your /public_html directory as the following will remove everything in that directory)

rm -rf ~/public_html ln -s ~/myapp/public ~/public_html

–Now we need to enable passenger, this is done by creating a file called .htaccess in your application public directory. Add the following entries in the file ./public/.htaccess under the location of your application root.


RailsBaseURI / PassengerAppRoot /home/myusername/myapp


RackBaseURI / PassengerAppRoot /home/myusername/myapp –Next, Setup your database and a database user in cPanel, and update your config/database.yml with this new database name, user, and password.

–Migrate or import your database(The command to do this is “rake db:migrate” from your application root path)

–Make sure any third party gems you need are installed, you can view the gems installed by running gem list—local , if there is a gem missing, email support to request the gem to be installed.

You will now be able to access your rails application at your domain, if there are any deployment errors, passenger will display an error message which should help you determine how to fix the error.


Source: RailsCarma

Offshore RoR Web Development Partner – RailsCarma

 RailsCarma specializes in Offshore Ruby on Rails Development and is located at Bangalore, India. RailsCarma offers specialized web development services using the Ruby on Rails platform. RailsCarma has high level of expertise and experience in developing ruby on rails or ror applications on PaaS platforms, both in standalone and Software as a Service formats.

 Projects that are designed, coded and maintained by RailsCarma consists of line of Business applications, industry specific applications in healthcare, smart grid areas where there is high level of API integration with other software and hardware systems.




RailsCarma has handled and delivered projects with more than 20k man hours of effort and durations more than 2 years. Visit the website to learn more on this.

You can contact us at for any of your Ruby on Rails related needs. We can work out a deal on an hourly, monthly or on a per project basis.

Besides this, we are also offering a couple of partnership opportunities as given below:

White Label Partnership

RailsCarma services can be resold by you under your own brand. Through this initiative, we aim to make it possible for you to easily add Ruby on Rails web development, which has huge demand right now, to your portfolio of services. With our services and your user base, we can both profit.

Become an Affiliate

If anyone you know has any Ruby on Rails related requirements then you could forward them to us. We can work together on a profit sharing basis on such projects.

Let us know if you are interested or if you have any queries regarding Ruby on Rails Consulting

Ruby on Rails: Our Choice for Web App Development

Over the last few years or so, we’ve used Ruby on Rails for development of our largest web world . Ruby on Rails is one of the so-called “opinionated” web frameworks out there. By opinionated, It assumes that you’re building a web app, which means that your app will live in a browser, probably connect to a database, need to create, read, update and delete records, and that your app’s files would be best served by being organized in a particular way, among many other things. Before Rails and other frameworks like it.

Find Ruby on Rails Developers for web application development. Ruby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language. It is intended to be used with an Agile development methodology that is used by web developers and programmers for rapid development.

every time you wanted to create a new web app, you’d have to rewrite the portions of the app that are common to every web app. By giving you sensible defaults to start from, it enables programmers to start at, say Level 7 on each web project, instead of Level 1. This cuts down time and cost on web application projects.

Another useful aspect of going with Ruby On Rails for a web project is that you’re using a framework which tons of other people use as well, which enables you to use plug-ins created by the community. That also saves you a lot of time and programming effort. For instance, most web applications are going to need some sort of login system. With Rails, you can either build your own custom solution, or you can choose from a bunch of plug-ins which are well documented and tested for security issues because of all the other people programming with Rails.

As of right now, the number of plug-ins for Rails is well into the hundreds of thousands. Basically, anytime that you decide you’d like to do something that other people might have a use for too (connecting to Face book, Twitter, uploading images, etc), chances are pretty good that it has already been written. Also, another benefit of using a framework that lots of other people use is that as a developer, it’s pretty easy to look at a Rails app you didn’t write and quickly figure out what’s going on, because the layout of the app is familiar.

These things combine to make Ruby on Rails every one number one choice for Web Development. It lets us get things done and go from idea to code in less time than anything else we’ve used.Then, you can’t mention Rails without mentioning Ruby, the programming language that it was built on top of. Ruby is a young language, built by a Japanese developer named Yukihiro Matz Matsumoto, and released in 1995. It is elegant, concise (in general, it takes a lot less Ruby code to get something done than it would in another language), and it’s easily readable/understandable compared to other languages.