7

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!

Andrei
  • 9,162
  • 7
  • 68
  • 103
  • 1
    I had the same impression while working through that guide. The guides in general are very helpful but that one seems to need a little updating/editing. You might also be interested in the four-part guide at: http://www.themodestrubyist.com/ [See bottom menu.] – TK-421 Feb 14 '11 at 15:04
  • Good engine tut: http://railscasts.com/episodes/277-mountable-engines – Yarin Jun 21 '13 at 15:58

3 Answers3

5

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

DanS
  • 15,309
  • 7
  • 47
  • 46
  • I am a bit confused in generators directory tree. May be I am wrong, but I think the guide describes slightly different directories than those generated by `rails g plugin my_plugin_name` – Andrei Feb 14 '11 at 14:40
  • 1
    Also, section 12.2 contains note: "*several plugin frameworks such as Desert and Engines provide more advanced plugin functionality.*", but the frameworks seem to be for Rails 2 mainly. Please, comment if it is wrong. – Andrei Feb 14 '11 at 14:43
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).

nathanvda
  • 48,109
  • 12
  • 108
  • 136
  • 1
    @nathanvda- This needs correction. The command for creating a new plugin is `rails plugin **new** your-plugin`. To create an *engine*, you must add either the `--full` or `--mountable` option. For an explanation of those options see my answer here: http://stackoverflow.com/a/17263429/165673 – Yarin Jun 24 '13 at 11:43
  • Thank you for the typo: indeed I omitted the `new`. Oops :) Last time I created an engine, I just did `rails plugin new engine-name` and then started filling it in. Using the `--full` option is much easier indeed. Thanks. – nathanvda Jun 24 '13 at 20:01
1

I recommend you have a look here:

https://github.com/krschacht/rails_3_engine_demo

Or the more famous:

https://github.com/josevalim/enginex

apneadiving
  • 110,730
  • 25
  • 209
  • 207
  • Very nice, thanks a lot! Perfect example in combination with tutorials at themodestrubyist.com recommended above by @TK-421. – Andrei Feb 14 '11 at 21:52
  • Note that engineX is not compatible with Rails 3.1+. It is also 'not needed'. – Confusion Feb 28 '12 at 07:21