まあ、普通の共通処理は、Applicationコントローラに書くよ、と。
フィルタの「フィルタを使った、フォーム認証」とかは、普通はココに書くよね。
class ApplicationController < ActionController::Base protect_from_forgery before_filter :check_logined private def check_logined …中略… end end
skip_before_filter :check_logined
rescue_from ActiveRecord::RecordNotFound, :with => :id_invalid private def id_invalid render 'shared/record_not_found', :status => 404 end
<p>URL[<%= request.fullpath %>]は存在しません</p>
URL[/books/100]は存在しません
class ApplicationController < ActionController::Base protect_from_forgery
<!DOCTYPE html> <html> <head> <title>Railbook</title> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> </head> <body> <%= yield %> </body> </html>
<html><head> …中略… <script src="/assets/application.js?body=1" type="text/javascript"></script> <meta content="authenticity_token" name="csrf-param" /> <meta content="ここにはトークンの文字列ねー" name="csrf-token" /> </head><body> …中略… <form accept-charset="UTF-8" action="/login/auth" method="post"> <div style="margin:0;padding:0;display:inline"> <input name="utf8" type="hidden" value="✓" /> <input name="authenticity_token" type="hidden" value="ここにはトークンの文字列ねー" /> </div> …中略… </form> </body></html>