Let’s Integrate Camaleon CMS into a Rails Application

Problem: The conventional approach of running a WordPress blog on /blog via a separate Nginx config introduces session inconsistencies, UI fragmentation and maintenance overhead. This guide shows how to integrate Camaleon CMS directly into your Rails app to serve the blog under the same domain and session context.

Prerequisites

  • Rails application (up and running)
  • Bundler
  • PostgreSQL / MySQL (compatible DB)

Step 1 — Add Dependencies

Add the following to your Gemfile:

# Camaleon CMS (forked for custom requirements)
gem "camaleon_cms", github: 'your-org/blog-cms', tag: '2.6.0'
gem 'draper', github: 'drapergem/draper'

The fork is based on owen2345/camaleon-cms. Maintain your own fork to apply any application-specific patches without depending on upstream.

Step 2 — Install the Gem

bundle install

Step 3 — Run the CMS Generator

rails generate camaleon_cms:install

This scaffolds the necessary initializers and configuration files.

Step 4 — Generate Migrations

rake camaleon_cms:generate_migrations

Step 5 — Configure config/system.json

{
  "share_sessions": true,
  "default_user_role": "client",
  "users_share_sites": true,
  "db_prefix": "blog_",
  "relative_url_root": "blog",
  "auto_include_migrations": false,
  "hooks": {},
  "admin_path_name": "admin",
  "name": "YourAppName",
  "description": "Your App Blog",
  "title": "Your App Blog Title",
  "version": "",
  "compatibility": "",
  "author": ""
}

Key settings to note:

  • share_sessions: true – shares the Rails session with the CMS, eliminating separate login flows
  • relative_url_root: "blog" – mounts the CMS at /blog within your existing app
  • db_prefix: "blog_" – namespaces CMS tables to avoid conflicts with your app’s schema

Step 6 — Move Plugin Routes to routes.rb

The CMS installer places gem-loading logic in the Gemfile. Move it to config/routes.rb instead:

# config/routes.rb

##### Camaleon CMS — include all gems for plugins and themes #####
require './lib/plugin_routes'
instance_eval(PluginRoutes.draw_gems)

This ensures CMS routes are registered within Rails’ routing layer rather than at gem-load time.

Step 7 — Run Migrations

rake db:migrate

Step 8 — Complete Setup via the Web Installer

Start your server and navigate to:

http://localhost:3000/blog/admin/installers

Follow the on-screen installer to configure the CMS site, admin credentials and initial settings.

Why This Approach:

+------------------+--------------------------------+-----------------------------------+
| Concern          | WordPress on Nginx             | Camaleon in Rails                 |
+------------------+--------------------------------+-----------------------------------+
| Session sharing  | Requires custom SSO or         | Native via share_sessions: true   |
|                  | cookie hacks                   |                                   |
+------------------+--------------------------------+-----------------------------------+
| UI consistency   | Separate theme/styles          | Shared Rails layouts possible     |
+------------------+--------------------------------+-----------------------------------+
| Deployment       | Two apps to deploy and monitor | Single Rails process              |
+------------------+--------------------------------+-----------------------------------+
| Auth             | Separate user DB               | Shared user model                 |
+------------------+--------------------------------+-----------------------------------+

Leave a Reply

Your email address will not be published. Required fields are marked *