次のように、Rails アプリに ActiveModel クラスを設定しました。
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
私は本当にこれを行うことができるようにしたい:
thingy = MyThingy.new(params)
thingy.update_attributes(:favorite_color => :red, :stuff => 'other stuff')
自分で update_attributes を書くこともできますが、どこかに存在するような気がします。そうですか?