# rails_pages Static pages on Rails. ## Installation ``` $ gem install rails_pages ``` ```ruby # Gemfile gem 'rails_pages' ``` ## Usage Note that nested page directory structures are accepted by default. Create static pages: ``` $ mkdir app/views/rails_pages $ touch app/views/rails_pages/page.html.erb ``` Visit pages `http://0.0.0.0:3000/pages/page`. ### Generating resources ``` $ rails generate rails_pages:scaffold products ``` Would generate the following: ```ruby # app/controllers/products_controller.rb class ProductsController < RailsPages::PagesController end ``` ```ruby # spec/controllers/products_controller_spec.rb require 'spec_helper' describe ProductsController do end ``` ```ruby # config/routes.rb resources :products, :only => :show, :format => false, :constraints => { :id => /.+?/ } ``` Create static pages: ``` $ mkdir app/views/products $ touch app/views/products/product.html.erb ``` Visit pages `http://0.0.0.0:3000/products/product`. ## Routing Link to pages with [named helpers][named-helpers]: [named-helpers]: http://guides.rubyonrails.org/routing.html#overriding-the-named-helpers ```erb <%= link_to 'Page', page_path('page') %> ``` Define root path: ```ruby # config/routes.rb root 'pages#show', :id => 'home' ``` Define root-level resource routes: ```ruby # config/routes.rb get '/:id' => 'pages#show', :as => :page, :format => false, :constraints => { :id => /.+?/ } ``` Exclude specific pages from resource routes: ```ruby :constraints => { :id => /.+?(? 'product' } it 'responds successfully with an HTTP 200 status code' do expect(response).to be_success expect(response.status).to eq(200) end it 'renders requested template' do expect(response).to render_template('product') end it 'inherits layout from ApplicationController' do expect(response).to render_template('layouts/application') end end end ``` ## License This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to