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 attr_accessor in the model and instead want to dynamically add virtual features to one result.

For example,

  user = user. A # user has the following features: Name, Email, Password   

What do I like to say Add (without using attr_accessor ) a virtual characteristic status to user , is it possible?

You should do this:

  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

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -

java : convert string value to int -