Is there a way to make Rails ActiveRecord attributes private?

Viewed 13192

By default, ActiveRecord takes all fields from the corresponding database table and creates public attributes for all of them.

I think that it's reasonable not to make all attributes in a model public. Even more, exposing attributes that are meant for internal use clutters the model's interface and violates the encapsulation principle.

So, is there a way to make some of the attributes literally private?

Or, maybe I should move on to some other ORM?

7 Answers
Related