# AR private methods

**URL:** <https://www.ruby-forum.com/t/ar-private-methods/189950>\
**Category:** Rails\
**Created:** [June 10, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/ar-private-methods/189950 "2010-06-10T13:10:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6bbea6/32.png) [@jarl](https://www.ruby-forum.com/u/jarl)\
**Post date:** [June 10, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/ar-private-methods/189950/1 "2010-06-10T13:10:35Z")

</div>

Hi.

I have an AR model named Order, and a field in the DB named expired. I  
dont want this field to be modified from outside the model.

Therefore I have declared a private method expired=(value) in my Order  
model.

This works fine in development and production; If I call o.expired =  
nil I get a “NoMethodError: Attempt to call private method”, and if I  
use o.update\_attributes(expired =\> nil) I get  
“ActiveRecord::UnknownAttributeError: unknown attribute: expired”.

However in test environment donot get such exceptions. I can easily  
use my private methods in my test environment, which is not what I  
expected.

Any ideas?

Jarl
