alias_method on ActiveRecord::Base results in NameError

前端 未结 1 432
旧巷少年郎
旧巷少年郎 2021-02-12 20:03

I have a model inheriting directly from ActiveResource::Base, and I\'m trying to run alias_method for most of the columns in the record\'s table, but t

相关标签:
1条回答
  • 2021-02-12 20:53

    According a site I found, you're supposed to use alias_attribute instead:

    The problem is that ActiveRecord doesn't create the accessor methods on the fly until the database connection is live and it has parsed the table schema. That's a long time after the class has been loaded.

    class LeadImport::Base < ActiveRecord::Base
      alias_attribute :address_1, :address_line_1
    end
    
    0 讨论(0)
提交回复
热议问题