# Newbie before\_filter question

**URL:** <https://www.ruby-forum.com/t/newbie-before-filter-question/58023>\
**Category:** Rails\
**Created:** [April 17, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/newbie-before-filter-question/58023 "2006-04-17T20:31:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 17, 2006, 8:31pm UTC](https://www.ruby-forum.com/t/newbie-before-filter-question/58023/1 "2006-04-17T20:31:25Z")

</div>

I’ve successfully gotten acts\_as\_authenticated working. Currently the  
before\_filter line for my admin screen is like this:

class AdminController \< ApplicationController

```
    include AuthenticatedSystem
    before_filter :login_required

```

Only issue I have now is that anyone logged in can access that screen.  
I’d like to differentiate between a regular user and admin. I saw  
something in the recipe’s book but it’s not quite what I’m looking for.  
All I want is an extra check.

If I create a new boolean field in my user database (call it is\_admin),  
is there a way I can also have the before filter check to see if that  
field is true? What would be the correct syntax for that?

Thanks…  
Vince

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 17, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/newbie-before-filter-question/58023/2 "2006-04-17T20:45:10Z")

</div>

Vince W. wrote:

> I’d like to differentiate between a regular user and admin. I saw

Sounds like you need Ezra’s ACL plugin:

[http://brainspl.at/articles/2006/02/20/new-plugin-acl\_system](http://brainspl.at/articles/2006/02/20/new-plugin-acl_system)

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [April 17, 2006, 9:22pm UTC](https://www.ruby-forum.com/t/newbie-before-filter-question/58023/3 "2006-04-17T21:22:23Z")

</div>

> Sounds like you need Ezra’s ACL plugin:

I’d rather not use a plugin just for something this simple…

I added this to my application.rb and added an extra check to my  
before\_filter in the admin controller.

```
    def check_authorization
            user = User.find(session[:user])
            unless user.level == 100
            flash[:notice] = "you are not an admin"
            return false
    end
    end

```

It works… but the flash isn’t quite where I want it to be. I’ll keep  
playing around, but if anyone has a simple suggestion to improve it…

Thanks
