CMS9 - CMS Admin module for Rails

March 30th 2020

In these modern times, it is almost impossible to find a web-site which does not have some sort of Blog/Post functionality. For the simplicity and ease of content creation, Content Management Systems (CMS) have been become very popular. CMS in general is an application designed to create, manage or publish content.

Ruby on Rails is an open source web application framework which can be used to create a CMS. To avoid creating and writing a bunch of code over and over we have created a simple engine that behaves as Content Management System called CMS9.

CMS9 is a library for Rails apps that automatically generates a CMS dashboard. CMS9 dashboard gives non-technical users a clean interface that allows them to create, edit, search, and delete definitions, field types and posts related to it. CMS9 provides complete CRUD functionality. 

In this way it is easy to create the structure of some Blog, Post or any other form, to add, remove or change fields via user interface and the best thing is that you can use it easily in your app.


Installing and Using Gem


To add CMS9 engine to your app you need to add gem in  Gemfile:
# Gemfile
gem "cms9"

Re-bundle, then run the installer:
$ rails generate cms9:install [DEF_ROUTE]

Install generator will mount CMS9 route, add current_user configurator initializer and additional configuration for Ckeditor.
Then run:
$ rails db:migrate

Restart your server, and visit http://localhost:3000/cms9 (or where you have defined CMS9 to be mounted) to see your new CMS9 dashboard in action.

On the dashboard, you can create a Post Type, where you define the fields which this form will contain, as text, text area, number, select, multiple select, image, date, time, date_time. 

Once when you have created the form for a specific post type (example Blog), you can populate this form. 

CMS9 blogs

To display populated values in your app, follow these steps: 

1. Generate controller Posts
$ rails g controller Posts

2. Add routes in routes file:
root 'posts#index'

3. In the Posts controller create a method for the index page.
def index
  if params[:name].blank?
    @posts = Cms9::Post.all.limit(20).order('created_at desc')
    post_definition = Cms9::PostDefinition.where(name: params[:name]).first
    @posts = post_definition.posts

In your view for the index page you can access the values of each field , just by changing the name of the field I.E.:

post.field(‘Field Name’)

You can make any kind of layout for your posts and show them however you want. Once you made a simple layout, you are ready to create as many posts as you want. It's that easy.

The gem and documentation are available on the GitHub repository:, and there is also a demo app on repository:

Popular posts

Don’t miss a thing!

Subscribe to our newsletter for the latest
news and job openings at Klika.

Thank You For Subscribing!

Cookies help us deliver our services. By using our services, you agree to our use of cookies.