2

Sorry if this is a newbie question but what exactly is the difference between the gem structure of a Ruby gem vs. Rails gem.

Strictly speaking, all Rails gems are also Ruby gems, but not the other way around. So what additional files are required to make a ruby gem into a Rails gem.

For example, in this post, Building a ruby gem for Rails applications, the top answer suggests that all Rails gems need an init.rb. But then I found some rails gems that don't have the init.rb file. Here is an example: https://github.com/collectiveidea/awesome_nested_set

Basically, I want to write a Rails gem. I find a lot of tutorials on writing Ruby gems, but I just want to make sure it works for a Rails app.

Community
  • 1
  • 1
User314159
  • 7,065
  • 9
  • 36
  • 60
  • A "Rails gem" is just a gem that is meant to be used along side Rails. It probably lists Rails or one of the ActiveRecord libraries as a dependency. – user229044 Feb 25 '14 at 23:53
  • Just for curiosity, why do you want to spend your time writing a gem? Why not start out by getting more familiar with ruby and rails and then tackle more advanced projects later. – Scott Hillson Feb 25 '14 at 23:58

1 Answers1

1

To put it simply, rails IS a ruby gem. A ruby gem is a ruby gem, and some are just built specifically for use with rails.

It's worth noting that gems and plugins are different, and you might be confusing the two:

Difference between plugins and Ruby gems?

Community
  • 1
  • 1
Scott Hillson
  • 869
  • 1
  • 12
  • 27