# Preventing read access to a model

**URL:** <https://www.ruby-forum.com/t/preventing-read-access-to-a-model/161739>\
**Category:** Rails\
**Created:** [March 1, 2009, 11:35pm UTC](https://www.ruby-forum.com/t/preventing-read-access-to-a-model/161739 "2009-03-01T23:35:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![evan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/54ee81/32.png) [@evan](https://www.ruby-forum.com/u/evan)\
**Post date:** [March 1, 2009, 11:35pm UTC](https://www.ruby-forum.com/t/preventing-read-access-to-a-model/161739/1 "2009-03-01T23:35:36Z")

</div>

In a model are there any methods that are called before providing  
access to the model?

I’m exploring ways to enforce privileges in my app. Wondering if I can  
define some sort of “before” method in the model to prevent read  
access to the model unless certain conditions are true.

Thanks.

Evan

---

<div class="post-metadata">

**Author:** ![evan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/54ee81/32.png) [@evan](https://www.ruby-forum.com/u/evan)\
**Post date:** [March 2, 2009, 4:55am UTC](https://www.ruby-forum.com/t/preventing-read-access-to-a-model/161739/2 "2009-03-02T04:55:28Z")

</div>

Go to [http://api.rubyonrails.org/](http://api.rubyonrails.org/) read about ActiveRecord::Callbacks

See also restful\_authentication gem and simple\_access\_control plugin -  
use them both.
