-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
class Book include Mongoid::Document field :t, :as => :title end b = Book.new b.t # => NoMethodError: undefined method `t' for #<Book _id: 4f0b4d99ad8a54813e000002, _type: nil, t: nil> b.title # => nil b.title = "Hey" b.t # => "Hey" b.title_changed? # => NoMethodError: undefined method `title_changed?' for #<Book _id: 4f0b4d99ad8a54813e000002, _type: nil, t: "Hey"> b.t_changed? # => true
This seems confusing: I have make sure to use the aliased label name all the time, else I'm vulnerable to NoMethodErrors. However, when checking dirty fields, I have to use the original field names.
I think this should be that the original field name should always work, and it would be nice if <code>[alias]_changed?</code> also worked. Let me know if you'd like me to split these out into multiple issues, etc.
Jon