ruby - Rails 3 add virtual attribute dynamically -
My setup: Rail 3.0.9, Ruby 1.9.2
I have reasons to do this But what I need is a way to dynamically add a virtual characteristic to an active sequence of results. This means that I am not using For example, What do I like to say Add (without using You should do this: attr_accessor in the model and instead want to dynamically add virtual features to one result.
user = user. A # user has the following features: Name, Email, Password
attr_accessor ) a virtual characteristic
status to
user , is it possible?
users.each do | User | User.instance_eval DRF status example_variable_get ("@ position") end DEF status = (val) instance_variable_set ("@ position", val) end and end
Comments
Post a Comment