AR private methods.

13 views
Skip to first unread message

Jarl Friis

unread,
Jun 10, 2010, 7:09:19 AM6/10/10
to Ruby on Rails: Talk
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


Reply all
Reply to author
Forward
0 new messages