Page not found
マッチするルーティンが無かったときに
「Page not found」のページを出すためのはどうするのだったか?
と調べてみる。
"*anything"というパターンに対してルールを書けばよかったんでしたね。
map.conect "*anything", :controller => '/error', :action => 'not_found'
routes.rbの最後のルールとして上記のようにすればOKでしたね。
あと、controllerはマッチしているけどActionがない場合は、
上記の方法ではだめでした。
それで、以下のように、ApplicationContrller(ベースのコントローラ)のbefore_filterで
メソッドが見つからなければerrorページにリダイレクトするようにしてみました。
..これでいいのかな??
class ApplicationController < ActionController::Base helper :all # include all helpers, all the time before_filter :unkonwn_action ... 省略 .... def unkonwn_action if !respond_to?(params[:action] ) render(:file => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found") end end