Posted By

nate63179 on 02/16/10


Tagged


Versions (?)

Static pages controller


 / Published in: Ruby
 

  1. class PagesController < ApplicationController
  2.  
  3. layout 'default'
  4.  
  5. def index
  6. end
  7.  
  8. def show
  9. action_name = params[:path].join('/')
  10. if page_exist?(action_name)
  11. render :action => action_name
  12. else
  13. render :action => "pages/404", :layout => true, :status => 404
  14. end
  15. end
  16.  
  17. private
  18.  
  19. def page_exist?(page_name)
  20. file_path = File.join(RAILS_ROOT, "app", "views", "pages", "#{page_name}.html.erb")
  21. return true if File.exists?(file_path)
  22. end
  23. end

Report this snippet  

You need to login to post a comment.