Skip to content

Instantly share code, notes, and snippets.

@elle
Last active August 29, 2015 14:04
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 elle/b34da3560106027e6da8 to your computer and use it in GitHub Desktop.
Save elle/b34da3560106027e6da8 to your computer and use it in GitHub Desktop.
static pages
# This controller returns static pages
class PagesController < ApplicationController
end
# routes.rb
get "help", to: "pages#help"
get "about", to: "pages#about"
get "privacy", to: "pages#privacy"
# ApplicationController:
private
def not_found
raise ActionController::RoutingError.new('Not Found')
end
# or option 2: not handling sub dirs though and haven't tested that one
get "/pages/:page", to: "pages#show"
class PagesController < ApplicationController
def show
render params[:page] rescue ActionController::RoutingError, 'Not Found'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment