1

I have written an app, and I would like to be able to use parts of it in future apps.

Essentially I want to extract parts of my app out into a gem or module, so I can use it for future use.

Do I want to create a gem for this, or a module?

I've read http://guides.rubygems.org/make-your-own-gem/#more-files and

How to create and use a module using Ruby on Rails 3?

I want my gem/module to load routes into routes.rb, and I want it to possess views, models, and controllers. Which is the best option for me, and what are my first steps?

Community
  • 1
  • 1
Peege151
  • 1,562
  • 2
  • 21
  • 45
  • 3
    modules are usually specific to an apps functionality they are essentially helpers. Gems are libraries that act independently. In your case gem would be better. – Sam Nov 10 '14 at 01:39

1 Answers1

0

The best option in you case is to write a gem, because you can add it easily between projects, and even better update the code without copy and paste in all your projects.

You can start by reading the following articles:

  1. Oficial guide of rubygems, you can get the info of how a gem is structured http://guides.rubygems.org/make-your-own-gem/

  2. After understand how to create a simple gem, please use bundler :D, it have some generators, in Railscasts is an amazing tutorial http://railscasts.com/episodes/245-new-gem-with-bundler

  3. Time to deploy? use this gem to mage your deploys, it have some of best practices, like semantic versioning, tags for every new version https://github.com/svenfuchs/gem-release

  4. If you need some example, here is a simple gem that I did, it have a controller and some routes https://github.com/rderoldan1/md_simple_editor

rderoldan1
  • 3,517
  • 26
  • 33