Making a custom plugin/gem/engine for Rails 3 app

2019-04-07 03:30发布

问题:

I am following the guide http://edgeguides.rubyonrails.org/plugins.html and it seems to be slightly outdated. Could you have a look on it and tell me which sections should be done in a different way in Rails 3?

EDIT1: Links to alternative tutorials are also very welcome!

回答1:

You're right, that guide isn't the best (the last changelog entry is April 2010).

Instead, I'd recommend you read: https://github.com/radar/guides/blob/master/gem-development.md



回答2:

I bumped into this question, and the answers are now outdated. The railsguide is currently up to date: http://guides.rubyonrails.org/engines.html

The enginex gem has been integrated into rails, and creating an engine is now as simple as:

rails plugin new your-gem-name  --full

Much like the rails new command, this will create a new folder, containing a blank gem for you to fill in. This gem is automatically an engine. For more options (e.g. --mountable check the documentation).



回答3:

I recommend you have a look here:

https://github.com/krschacht/rails_3_engine_demo

Or the more famous:

https://github.com/josevalim/enginex