BrightContent, yet another cms / admin panel for Rails
Ruby HTML JavaScript CSS
Latest commit 908c986 Oct 10, 2016 @jvdp jvdp bump version


Gem Version Code Climate Build Status

Brightcontent, yet another rails CMS / admin panel

  • For developers, to make a custom CMS for non-technical users
  • No standard 'cms-modules', we hate those, making custom is easy enough
  • Built in the rails way, use your normals models, only controllers and views are provided
  • Only exception: Page model is provided with tree structure, sorting, hidden and pretty urls like /services/cleaning/houses
  • Supports Rails 4.2 and above
  • Strong Parameters support

Brightcontent preview


Include the gem in your Gemfile:

gem "brightcontent"
bundle install

Generate the initializer, copy migrations and edit routes file. This can be done via a generator. Migrate the database afterwards:

$ rails generate brightcontent:install
$ rails generate brightcontent:pages:install
$ rails generate brightcontent:attachments:install
$ rake db:migrate

Go to /admin and login with default user (email: / password: password).

Add a resource to Brightcontent

Lets say, we want to add projects. Just create the Project model the rails way:

$ rails g model Project name:string description:text
$ rake db:migrate

To add the resource to brightcontent run:

$ rails generate brightcontent:resource Project

Gratz! Projects can now be controlled with Brightcontent.


Using filter_fields you may define filters for your index pages:

class BlogsController < Brightcontent::BaseController
  filter_fields :author, :name

The above will render two filters on the blogs index page. Blog belongs to Author, therefore by default the filter is displayed as a drop-down list containing all authors that have blogs. The name-filter is displayed as a drop-down list containing all values for the name attribute found in the blogs table.


In order to control the way filters are displayed and how they behave you can supply options:

# Supplying options:
filter_fields author: { ... }, name: { ... }

# Combining filters without options and filters with options:
filter_fields :author, name: { ... }

Basically all options are delegated to SimpleForm::FormBuilder#input, such as :as, :input_html, and :label_method. Refer to Simple Form's documentation for more information.

Other options


Extends SimpleForm's :collection option. It also accepts a Proc, or method name as a symbol. It defaults to either a list of all existing values for the corresponding attribute or a list of all associated records in case of a belongs-to relationship.


Allows for specifying the Ransack search predicate to be used. Set it to false to avoid a predicate. Defaults to "cont" (contains) for string type filters (:string or :search) and to "eq" (equals) for all other types. It defaults to false if the field name refers to a ransackable scope. For more information refer to Ransack's documentation.


class BlogsController < Brightcontent::BaseController
  # Two default drop-down list filters:
  filter_fields :name, :author

  # Free form text filter, returns all blogs where name contains given query:
  filter_fields name: { as: :string, predicate: "cont" }

  # Same as above:
  filter_fields name: { as: :string }

  # Customized label:
  filter_fields author: { label: "Written by" }

  # Select filter with custom options:
  filter_fields name: { collection: ["Game reviews", "Programming tips", "Arthur's blog"] }

  # Belongs-to filter with custom options:
  filter_fields author: { collection: ->{ Author.order(:name) }, label_method: :display_name }

  # Or by means of a controller method:
  filter_fields author: { collection: :published_authors }

  # Or even a fully customized filter, using a fictitious custom SimpleForm input field:
  filter_fields author: { as: :remote_select, url: "/authors.json?order=name" }

  # Filter by start date:
  filter_fields created_at: { as: :date, predicate: "gteq", label: "Posted since" }

  # Filter by scope (see definition of Blog below):
  filter_fields exclude_inactive: { as: :select, collection: [["Yes", true], ["No", false]] }


  def published_authors

def Blog < ActiveRecord::Base
  scope :exclude_inactive, ->{ where(active: true) }

  def self.ransackable_scopes(auth_object = nil)


Pages gives you a Page model with tree structure and pretty urls. Every page relates to a specific path. For example, you could create a page with the path /about/team. The page is available on the url via current_page.

This adds an extra layer on top of your existing routes. However when there aren't any routes available for the specific url, Rails cannot render the page. Therefore it is best to add a catch-all route (at the very bottom of the file) for all general pages:

get "*path" => "pages#show", constraints:


The number of pages can be set in a controller by calling per_page 50.

If multiple page sizes are preferred, you can provide those sizes with

page_size_options [10, 25, 50, 100]

This will set the default page size to 10 and inject 4 page size options in the index views. The per_page value (if provided), will be ignored.