Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 896
user502052 Avatar asked Nov 14 '22 08:11

user502052


1 Answers

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.

like image 75
James Avatar answered Dec 19 '22 18:12

James