我想在我想要保存在我的控制器視圖文件夾的子目錄中的「boiler-plate」頁面上使用此技術(http://blog.hasmanythrough.com/2008/4/2/simple-pages)。RoR:查看和控制器子目錄?
我該怎麼做?以下似乎不起作用:返回「模板丟失」錯誤。
錯誤:
Missing template home/New_York_apartments.erb in view path app/views
/app
/controllers
home_controller.rb
/old_pages
home_controller.rb
/views
/home
about.html.haml
contact.html.haml
index.html.haml
/old_pages
New_York_apartments.html.haml
routes.rb
map.namespace :old_pages do
map.connect ':page', :controller => 'home', :action => 'show', :page => HomeController::PAGES
end
map.home ':page', :controller => 'home', :action => 'show', :page => HomeController::PAGES
controllers/home_controller.rb
class HomeController < ApplicationController
# boiler-plate pages
PAGES = ['about','contact']
def index
# homepage
end
def show
render :action => params[:page] # passed in our routes
end
end
controllers/old_pages/home_controller.rb
class OldPages::HomeController < ApplicationController
# boiler-plate pages
PAGES = [
'New_York_apartments' # apprently something to do with new york apartments; who knows
]
def show
render :action => params[:page] # passed in our routes
end
end