Last active
March 2, 2016 11:21
-
-
Save philoye/52758023654c06273c6c to your computer and use it in GitHub Desktop.
static-ish files in rails, while allowing for nesting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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