Deprecation warning for creating attribute 'currency'

前端 未结 2 1972
星月不相逢
星月不相逢 2020-12-19 03:08

I\'m using Rails 3.2.3 with the money-rails gem and I\'ve got a product model which has the following:

My model

class Product < ActiveRecord::Base         


        
相关标签:
2条回答
  • 2020-12-19 03:33

    Added 'currency:string' to my model

    0 讨论(0)
  • 2020-12-19 03:38

    Apparently in Rails 3.2 and above arbitrary attributes (attributes not stored in the database) are no longer allowed. There doesn't seem to be a way around it.

    Here is the commit for the deprecation message: https://github.com/rails/rails/commit/b2955edc and here is why: https://github.com/rails/rails/commit/50d395f96ea05da1e02459688e94bff5872c307b

    In your case price_cents and currency still need to be stored in the database and then your composed class will take it from there.

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