Skip to content

Instantly share code, notes, and snippets.

@philoye
Last active March 2, 2016 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philoye/52758023654c06273c6c to your computer and use it in GitHub Desktop.
Save philoye/52758023654c06273c6c to your computer and use it in GitHub Desktop.
static-ish files in rails, while allowing for nesting
class PagesController < ApplicationController
before_action :authorize!, :only => [ :welcome ]
def welcome
end
def show_doc
begin
render "/pages/docs/#{params[:page]}"
rescue ActionView::MissingTemplate
render template: "pages/404", status: 404
end
end
end
Rails.application.routes.draw do
controller :pages do
get :welcome
get '/docs/*page', action: :show_doc
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment