3

I'm trying to get some of the .attribute_changed? functionality from ActiveRecord::Dirty

I followed the example here: http://api.rubyonrails.org/v3.2.16/classes/ActiveModel/Dirty.html

but I got:

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

because of this line:

define_attribute_methods [:at, :job_type, :length]

so I tried NonPersistedAttributeMethods: https://stackoverflow.com/a/14467907/203915

but the override methods aren't working ('at' returns nil when it isn't)

what I've got:

def at
  @at
end
def at=(val)
  at_will_change! unless val == @at
  @at = val
end
Community
  • 1
  • 1
Mark Robinson
  • 1,479
  • 2
  • 15
  • 34
  • Seems to be the same problem answered here: http://stackoverflow.com/questions/13074582/problems-implementing-activemodel-dirty-rails-3-2-8 – Steve Sep 06 '14 at 04:13

0 Answers0