Cannot include module in model

前端 未结 3 974
清酒与你
清酒与你 2020-12-28 20:13

I\'m using

Ruby version              1.8.7
Rails version             3.0.3

I have a method called alive in every model of my rails app:

3条回答
  •  余生分开走
    2020-12-28 20:36

    I'm aware this is a pretty old question, the accepted answer did work for me, but that meant me having to re-write a lot of code because i have to change the module to a nested one.

    This is what helped me with my situation and should work with most of today's applications.(not sure if it'll work in the ruby/rails version in the question)

    instead of doing include use extend

    So as per the question, the sample code would look like:

    class Client < ActiveRecord::Base
      extend LifeControl   
    end
    

提交回复
热议问题