# TypeError =\> Symbol as array index

**URL:** <https://www.ruby-forum.com/t/typeerror-symbol-as-array-index/114367>\
**Category:** Rails\
**Created:** [September 11, 2007, 10:09pm UTC](https://www.ruby-forum.com/t/typeerror-symbol-as-array-index/114367 "2007-09-11T22:09:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![esox\_ch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4da419/32.png) [@esox\_ch](https://www.ruby-forum.com/u/esox_ch)\
**Post date:** [September 11, 2007, 10:09pm UTC](https://www.ruby-forum.com/t/typeerror-symbol-as-array-index/114367/1 "2007-09-11T22:09:15Z")

</div>

Hello,

I’ve got a controller, which I’d like to protect from being accessed by  
untrusted users. I saw that you can use before\_filter to do it.  
I tried before\_filter :filter on the page I’d like to protect and then  
creating a private method on the super class and it works. I’d now like  
to get some information from the controller … So I tried before\_filter  
ApplicationController on the controller and then :

def self.filter(controller)  
id = self.session[:user\_id]  
# some other stuff  
end

And now, I get an error at the line of session :

TypeError in AdministrationController#index  
Symbol as array index

Could you explain me why ?

Thanks a lot

---

<div class="post-metadata">

**Author:** ![esox\_ch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4da419/32.png) [@esox\_ch](https://www.ruby-forum.com/u/esox_ch)\
**Post date:** [September 13, 2007, 8:57am UTC](https://www.ruby-forum.com/t/typeerror-symbol-as-array-index/114367/2 "2007-09-13T08:57:45Z")

</div>

Hello,

I found my own answer : the method is statical (because of self) and  
session cannot be accessed from a statical context
