Best Practices for reusing code between controllers in Ruby on Rails

前端 未结 7 665
忘掉有多难
忘掉有多难 2020-11-29 16:06

I have some controller methods I\'d like to share. What is the best practice for doing this in ruby on rails? Should I create an abstract class that my controllers extend, o

相关标签:
7条回答
  • 2020-11-29 16:53

    I found that one effective way to share identical code across controllers is to have one controller inherit from the other (where the code lives). I used this approach to share identical methods defined in my controllers with another set of namespaced controllers.

    0 讨论(0)
提交回复
热议问题