# [Rails4][controller][note]controller筆記 ###### tags: `Rails4`,`controller`,`note` ### 定義全域方法 參考資料: https://stackoverflow.com/questions/5985761/how-to-call-applicationcontroller-methods-from-applicationhelper * 在application_controller內定義的methods可以在所有controller中被呼叫 * 若額外使用helper_method,可以讓view也能呼叫application_controller內的methods 範例: ```ruby class ApplicationController < ActionController::Base helper_method :foo def foo "bar" end end ```