Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created August 25, 2022 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igaiga/3bff6f8eac414d42b126e014e6f145ae to your computer and use it in GitHub Desktop.
Save igaiga/3bff6f8eac414d42b126e014e6f145ae to your computer and use it in GitHub Desktop.
class ParentController
before_action :something_method
private
def something_method
"Parent"
end
end
class ChildController < ParentController
# before_actionは書かない
private
def something_method
# 親クラスの同名メソッドをのっとる
"Childd"
# 必要ならsuperで親クラスのメソッドも呼べる
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment