Created
May 27, 2012 10:18
-
-
Save namutaka/2803188 to your computer and use it in GitHub Desktop.
レイアウト付きで静的ページを表示させるコントローラ
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
# | |
# レイアウト付きで静的ページを表示させるコントローラ | |
# | |
# routes.rb | |
# map.connect "/hoge/*paths", :controller => 'static_page', :action => 'index', :subdir => 'hoge' | |
# | |
class StaticPageController < ApplicationController | |
#viewファイルの配置場所を別途用意する | |
STATIC_VIEWS_BASE = "app/static_views" | |
append_view_path STATIC_VIEWS_BASE | |
def index | |
view_file_path = File.join(Rails.root, STATIC_VIEWS_BASE, | |
params[:subdir], params[:paths].presence || 'index') | |
render :file => view_file_path, :layout => true | |
rescue ActionView::MissingTemplate | |
raise MissingFile, "Cannot read file #{view_file_path}" | |
end | |
end | |
#ファイルパスを追加 | |
#・rake stats用 | |
#・rake doc:app用 | |
#・rake test | |
#テストフォルダの構成。 | |
#fixtureの構成。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment