Creating an Engine on Refinery CMS

refinerycms logo3

Refinerycms

‘Engines’ are nothing but ‘plug-ins’ which adds up extended functionality to the existing Refinery application. Engines installs in the “vendor/extensions” folder in a refinery app.

Engines will create a tab in the Admin panel of the Refinery CMS to control the information on the engine.This example demonstrates creating an engine in an existing refinery app. The environments used are Ruby 1.9.3, Rails 3.2.8 & Refinery cms 2.0.8.

Step#1

To create an engine, just execute the below command

rails generate refinery:engine engine_name attribute:type attribute:name

NB: The engine name should be in singular which will generate the structure in plural form.
For example we want a FAQ engine for our CMS which will be controlled by CMS admin

rails generate refinery:engine MyFaq question:string answer:text

Running the above command will create a new folder “extensions” under “vendor” directory and in the “extensions” the new engine “my_faqs” will be created.

Step#2

After that run the below commands to make it executable

bundle install
rails generate refinery:my_faqs
rake db:migrate
rake db:seed

Step#3

Restart the server to get the effect. You will find the new tab “My Faqs” has been added both in the menu section of the user section and admin section.

Login as Admin to manage your FAQs

How to customize an engine during creation?

Creating the engine with a namespace

rails g refinery:engine MyFaq title description:text --namespace FAQ

Creating the engine by skipping the frontend pages

It will add menu and form page in the admin section only. User section will be omitted

rails g refinery:engine MyFaq title description:text --skip-frontend

Leave a Reply