It takes three easy steps to install Ignition:
gem 'ignition'to your
Gemfileand run the
Mount Ignition's engine in your
mount Ignition::Engine => '/pages'
Create pages like normal templates in the
app/views/pagesdirectory. Use any format and template handler you like. They'll be available at
Secure - users cannot fetch pages outside of the
Nested pages - e.g.
http://my.app/pages/projects/hellowould load the template
Mountable at any path - e.g. you could mount to
/if you wanted pages like
/about, this will not conflict with your existing routes even if Ignition is mounted before you define the routes
URL helpers - use
ignition_engine.page_urlto link to your static pages.
Works with custom (and multiple)
By default Ignition does not perform any caching, as this can interfere with the application's layout if it is dynamic.
There are three types of caching:
:none- does not perform any caching (default).
:page- caches the entire page using Rails' page caching. As page caching was removed form Rails 4, you'll need to install the
actionpack-page_cachinggem for this option to work.
:page_without_layout- caches the page using Rails' action caching. The layout is not included in the cache, therefore this option is suitable if your layout is dynamic. However, it's probably also not very useful, unless you do some long-running computation in your static page templates. As action caching was removed from Rails 4, you'll need to install the
actionpack-action_cachinggem for this option to work.
These can be set in the
config/application.rb file or any of the
config/environments/*.rb files, like so:
config.ignition.cache = :page
By default Ignition will make your static pages use the
This is also the Rails default. It can be changed like so in the
config.ignition.layout = 'my_page_layout'
By default Ignition will try to include pages in a folder named
app/views folder. You can change this
pages prefix by changing the
following setting inside the
config.ignition.view_prefix = 'static_pages'
The only reason you would probably want to do this is if
pages conflicts with
a controller and set of views you already have.
ignition_engine. in front of URL helpers
This can be accomplished by placing the following code in your
ApplicationHelper module, found in the
[:page_path, :page_url].each do |method| define_method(method) do |*args| ignition_engine.send(method, *args) end end
Ignition is available under the MIT license, see the