/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class PagesController < ApplicationController layout 'default' def index end def show action_name = params[:path].join('/') if page_exist?(action_name) render :action => action_name else render :action => "pages/404", :layout => true, :status => 404 end end private def page_exist?(page_name) file_path = File.join(RAILS_ROOT, "app", "views", "pages", "#{page_name}.html.erb") return true if File.exists?(file_path) end end