How can I extend ApplicationController in a gem?

后端 未结 4 966
小鲜肉
小鲜肉 2020-12-15 20:32

I thought I\'d come up with a slick way to extend ApplicationController in a Rails 3.x gem.

In my gem\'s lib/my_namespace/my_controller.rb, I had:

4条回答
  •  抹茶落季
    2020-12-15 21:16

    Here is a Gist that shows how to access the class of the subclass and store it in an instance variable and access it in the before and after filters. It uses the include method.

提交回复
热议问题