Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to learn how to write a gem that integrates with rails, what is the best gem to learn from?

I want to learn how to write a gem that integrates with rails (3) at some level. I'm learning towards something that hooks into activerecord as I would love to learn that, but not sure how advanced that would be.

This is for learning purposes, so would there be a gem that I could read the source that you would recommend?

Something interesting yet approachable for someone trying to learn.

like image 897
Blankman Avatar asked Jun 15 '11 21:06

Blankman


People also ask

What is a Rails gem?

Gems in Rails are libraries that allow any Ruby on Rails developer to add functionalities without writing code. You can also call Ruby on Rails gems as plugins for adding features. A Ruby gem enables adding features without creating the code again and again.

What is difference between gem and plugin Rails?

The basic difference is a gem is something that needs to be installed on the system running your Rails application, whereas a plugin is deployed along with your application. More specifically, plugins live in vendor/plugins whereas gems need to be install using rake gem install gem_name.


2 Answers

This guide: The Basics of Creating Rails Plugins should be a good start for you.

like image 117
cmwright Avatar answered Sep 28 '22 17:09

cmwright


If you are using Rails3, I think the gem 'devise' is a good example to learn.

and the basic of creating a gem using bundler, see this post: https://github.com/radar/guides/blob/master/gem-development.md

like image 21
Siwei Avatar answered Sep 28 '22 17:09

Siwei