ActiveRecord :: Dirty在Rails 3.2.16中不起作用

时间:2014-02-11 11:45:06

标签: ruby-on-rails ruby activerecord ruby-on-rails-3.2

我正试图获得一些.attribute_changed? ActiveRecord :: Dirty

的功能

我按照这里的示例:http://api.rubyonrails.org/v3.2.16/classes/ActiveModel/Dirty.html

但我得到了:

ArgumentError (wrong number of arguments (3 for 0)):
  app/models/appointment.rb:5:in `<class:Appointment>'

因为这一行:

define_attribute_methods [:at, :job_type, :length]

所以我尝试了NonPersistedAttributeMethods:https://stackoverflow.com/a/14467907/203915

但覆盖方法不起作用('at'返回nil,否则为

我得到了什么:

def at
  @at
end
def at=(val)
  at_will_change! unless val == @at
  @at = val
end

0 个答案:

没有答案