A markdown pages system for Selectra's apps.
Add the following line in your
gem 'selectra_pages', '>= 0.0.3'
bundle install in the root folder of your app.
Once that's done, use this rake task to copy the migration file to your app and the run it.
rake selectra_pages_engine:install:migrations rake db:migrate
To add the pages system, add the following in your
config/routes.rb file :
This will tell your app to load a page found by it's
url field when you visit
Alternatively, it is possible to use pages as default component of the app :
This will allow to visit pages using
title string(100) # Title of the page body text # Body of the page url string(100) # URL used to find the page classes string(100) # CSS Classes that apply to the page description string(170) # Meta Description of the page
There is only one view provided by SelectraPages, it's the
You can override it by creating a file named
# app/views/pages/show.html.erb <h1><%= @page.title %></h1> <%= markdown @page.body %>
The pages use by default a Markdown syntax, that why this gem depends on
If you override the view, you can use anything you want instead of markdown.
Here you can choose to use textile if you prefer it. Just be sure to install required libraries, RedCloth in that case.
# app/views/pages/show.html.erb <h1><%= @page.title %></h1> <%= textilize @page.body %>
Pages are cached automaticaly when caching is enabled.
SelectraPages provides a cache sweeper called
PageSweeper. You can use it in your ActiveAdmin configuration:
ActiveAdmin.register Page do controller do cache_sweeper :page_sweeper end end
SelectraPages provides a generator to create ActiveAdmin resource for the Page model.
rails generate selectra_pages:admin