tôi đã thiết lập một lớp ActiveModel trong ứng dụng Rails của tôi như thế này:ActiveModel có mô-đun bao gồm phương thức "update_attributes" không?
class MyThingy
extend ActiveModel::Naming
extend ActiveModel::Translation
include ActiveModel::Validations
include ActiveModel::Conversion
attr_accessor :username, :favorite_color, :stuff
def initialize(params)
#Set up stuff
end
end
Tôi thực sự muốn để có thể làm điều này:
thingy = MyThingy.new(params)
thingy.update_attributes(:favorite_color => :red, :stuff => 'other stuff')
tôi chỉ có thể viết update_attributes trên của riêng tôi, nhưng tôi có cảm giác nó tồn tại ở đâu đó. Phải không?
Có bất kỳ giác ngộ cho các phiên bản ray mới hơn chưa? – schmijos