How to get and set model data from inside a Rails model
How to get the my_var
model variable:
puts self.var
or
puts var
How to set the my_var
model variable:
self.var = "new value"
Note that when setting, you must prefix with self.
, unlike when getting. Also note that @var
will not work for setting or getting model data, ever.