Project

pages

0.02
No commit activity in last 3 years
No release in over 3 years
Pages.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

> 3.2
 Project Readme

Pages

Build Status Dependency Status Code Climate

Simple dynamic yet static pages for a Rails app

Installation

In your Gemfile add the following:

gem 'pages'

Then you can either create a app/views/pages directory

mkdir app/views/pages

Or run the generator

rails g pages:setup

Usage

Simply define new pages in your routes

Rails.application.routes.draw do
  # Define a single page
  page :about

  # Define multiple pages
  pages :contact, :team
end

This will expand to:

get '/about' => 'pages#about', :as => :about

Then just create a new view

touch app/views/pages/about.html.erb

And create whatever content you want!

If you'd like to modify the routes that Pages generates, you can alter the page parameter by passing an options hash containing a block. This is particularly useful for creating SEO-friendly routes:

page :press_kit, :transform => lambda { |page| page.dasherize }

would expand to:

get '/press-kit' => 'pages#press_kit', :as => :press_kit

Namespacing

You can easily namespace pages:

namespace :work do
  pages :client_1, :client_2
end

This will create a Work::PagesController dynamically if one does not already exist. If you chose to create your own it should always inherit from ::PagesController. Your views should be put into app/views/work/pages/

Path Helper Overrides

You can optionally override the path helpers by passing a hash to :as

pages '404', '500', as: { '404' => 'not_found', '500', => 'server_error' }

Your views will be app/views/pages/not_found.html and app/views/pages/server_error.html and path helpers will be not_found_path and server_error_path but the urls will be /400 and /500.

Authors

Brian Cardarella

We are very thankful for the many contributors

Versioning

This gem follows Semantic Versioning

Want to help?

Stable branches are created based upon each minor version. Please make pull requests to specific branches rather than master.

Please make sure you include tests!

Unles Rails drops support for Ruby 1.8.7 we will continue to use the hash-rocket syntax. Please respect this.

Don't use tabs to indent, two spaces are the standard.

Legal

DockYard, LLC © 2012

@dockyard

Licensed under the MIT license