1

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?

uday
  • 8,544
  • 4
  • 30
  • 54
Karthick
  • 41
  • 4

1 Answers1

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