Skip to content

Creating plugins gems to extend Para

Valentin Ballestrino edited this page Nov 29, 2016 · 4 revisions

These are notes for a future wiki entry.

Plugins API :

  1. Use the para-gem_name format
  2. Make it a Rails engine (to Rails autoloading to work), without isolating the namespace
  3. Add a #config method to the base module (Para::GemName)
  4. Add a Para::GemName::Routes module to define pluggable routes
  5. Add a Para::GemName.config.javascript_includes to include javascript assets to the base admin.js file loaded by para
  6. List hooks available

4. Add a Para::GemName::Routes module to define pluggable routes

If your plugin needs to add routes to the app, you can create a Para::Plugins::Route subclass and implement the draw method.

To namespace the routes with your plugin's name, use the plugin method to wrap your routes. Using plugin :my_gem would scope controller lookup to the para/my_gem namespace, which should be the default namespace for your code in a classical Para plugin.

module Para
  module MyGem
    class Routes < Para::Plugins::Routes
      def draw
        plugin :my_gem do
          crud_component controller: :special_resources
        end
      end
    end
  end
end

Note : Do not forget to load the routes into your gem by autoloading or requiring the file at the top of your gem's namespace.

Clone this wiki locally