user502052
user502052

Reputation: 15257

Updating to Rails 3.2.2: How to properly move my plugin from the '/vendor' to '/lib' directory?

I am upgrading Ruby on Rails from 3.1 to 3.2.2 and I would like to know what I should make and at what I should be care in order to properly move my vendor plugin (note: it is not a gem and at this time I am not planning to make that a gem) from the directory /vendor to /lib as well as wrote in the official documentation:

Rails 3.2 deprecates vendor/plugins and Rails 4.0 will remove them completely. You can start replacing these plugins by extracting them as gems and adding them in your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.

I refer mostly to the "an appropriate initializer in config/initializers/my_plugin.rb": What code should I put in that file?

More: Do you have some advice or alert on making the above process?

Upvotes: 5

Views: 1117

Answers (1)

James
James

Reputation: 4807

The initializer should contain the appropriate requires and other startup related tasks that are necessary for your plugin to work correctly. It's difficult to help you without real code examples from your app but this link should help you get started.

http://code.coneybeare.net/how-to-convert-simple-rails-23-style-plugins

The example in the link requires the plugin (now in the lib directory) and adds a module to ActiveRecord::Base.

Upvotes: 1

Related Questions