Search code examples
ruby-on-railsruby-on-rails-3rubygemsruby-on-rails-plugins

Rails 3 - differences between Engines and Plugins


Unfortunately official guide for creating Rails plugins is outdated: http://guides.rubyonrails.org/plugins.html and I didn't find any good tutorial for creating engines only this code: https://github.com/mankind/Rails-3-engine-example and enginex https://github.com/josevalim/enginex were helpful.

So... what are differences between plugins and engines in Rails 3? (I'm thinking of plugins and engines with controllers and views)?

And how can I create plugin with views and controllers? Or maybe in Rails 3 it's better to use engines? Can I use main app model (for example user model, logged user information) inside my engine?


Solution

  • Engines are just required as gems in your app. Since Rails 3.1 you even don't have to require their assets such as .css or .js

    In Rails 2.x, Engines didn't exist, so plugins enabled people to have these functionalities but all code was copied inside the app.