Suppose I have a model User
with two attributes: :name
and :age
. I want the :age
column to be accessible only to "def manipulate_age()"(some method). This also includes, user.update_attributes!(:age => 10)
is expected to throw an exception. Is it possible to do that in Rails 3 way?
Asked
Active
Viewed 60 times
1
1 Answers
0
If you do not list name and age in attr_accessor, you cannot read and write those fields directly.

Paulo Fidalgo
- 21,709
- 7
- 99
- 115