Guest User

Untitled

a guest
Apr 25th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. class PagesController < ApplicationController
  2.  
  3. verify :params => :name, :only => :show, :redirect_to => :root_url
  4. before_filter :ensure_valid, :only => :show
  5.  
  6. def show
  7. render :template => "pages/#{current_page}"
  8. end
  9.  
  10. protected
  11.  
  12. def current_page
  13. params[:name].to_s.downcase
  14. end
  15.  
  16. def ensure_valid
  17. unless template_exists?("pages/#{current_page}.html.erb")
  18. render :nothing => true, :status => 404 and return false
  19. end
  20. end
  21.  
  22. end
Add Comment
Please, Sign In to add comment