# Strange: Can't use action 'session'

**URL:** <https://www.ruby-forum.com/t/strange-cant-use-action-session/48768>\
**Category:** Rails\
**Created:** [November 24, 2005, 9:40am UTC](https://www.ruby-forum.com/t/strange-cant-use-action-session/48768 "2005-11-24T09:40:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [November 24, 2005, 9:40am UTC](https://www.ruby-forum.com/t/strange-cant-use-action-session/48768/1 "2005-11-24T09:40:00Z")

</div>

Visiting the url:  
[http://localhost:3000/schedules/session](http://localhost:3000/schedules/session)

Does not execute the action ‘session’

For some odd reason (that I’d like to discover), rails is not executing  
my ‘session’ action. If i get rid of the sessions.rhtml file in the  
views dir, then webrick just hangs and never returns from the request.  
I can go and visit other pages in the app but not that one.

Here is the controller class:

class SchedulesController \< ApplicationController  
layout “standard”

def index  
# semester list  
@semester = Session.find( :all, :conditions =\> “season\_id != 0” )  
end

def semester  
# list of sessions  
@sessions = Session.find( :all,  
:conditions =\> "season\_id = " + params[:season] + " and year = " +  
params[:year] )  
end

def session  
# list of classes  
#@classes = AClass.find( :all, :conditions =\> "session\_id = " +  
params[:session] )  
#@classes = AClass.find( :all, :conditions =\> “session\_id = 3” )  
@c = “hi”  
logger.info( @c )  
end

def class\_info  
# class information  
@c = “hi”  
end

end

And here is the view:

# Session

\<%= @c.class %\>

For the current code, @c.class print NilClass  
logger.info( @c ) is never executed either as i do not see any output  
(‘hi’) in the log file.

What could be blocking the session action from executing? I created a  
test rails app with one controller with one action (session) and it  
worked fine. I have a database with a table called sessions. I have a  
model called Session stored in session.rb in the models dir. I’ve tried  
removing the model file and restarting webrick with no results.

Any help would be greatly appreciated. I’ve been playing with this for  
hours.

Thanks.

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [November 24, 2005, 9:54am UTC](https://www.ruby-forum.com/t/strange-cant-use-action-session/48768/2 "2005-11-24T09:54:29Z")

</div>

Am 24.11.2005 um 09:40 schrieb Michael L.:

> Visiting the url:  
> [http://localhost:3000/schedules/session](http://localhost:3000/schedules/session)
> 
> Does not execute the action ‘session’

I guess this is related to the fact that ActionController::Base has a  
“session” method that returns the current session hash. I don’t think  
you can have a “session” action since the method would overwrite the  
session method of the Base class. You won’t be able to have a  
“request” action either.

Regards

Manuel H.

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [November 24, 2005, 10:22am UTC](https://www.ruby-forum.com/t/strange-cant-use-action-session/48768/3 "2005-11-24T10:22:42Z")

</div>

On Thu, 24 Nov 2005 09:40:00 +0100  
Michael L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Visiting the url:  
> [http://localhost:3000/schedules/session](http://localhost:3000/schedules/session)
> 
> Does not execute the action ‘session’
> 
> For some odd reason (that I’d like to discover), rails is not  
> executing  
> my ‘session’ action. If i get rid of the sessions.rhtml file in the  
> views dir, then webrick just hangs and never returns from the request.

> I can go and visit other pages in the app but not that one.

The method ‘session’ is already used to accessed the session in a  
controller. So it’s a bad idea to have an action named ‘session’ anyway.  
I cannot tell you the details what’s happening if you do so (maybe the  
session method is created on the fly when loading the sesson and  
therefore overwriting your session method), but I came to the conclusion  
that one should just select a different name.

HTH  
Morus

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [November 24, 2005, 5:10pm UTC](https://www.ruby-forum.com/t/strange-cant-use-action-session/48768/4 "2005-11-24T17:10:06Z")

</div>

Thanks for the responses.

They make some sense. I saw the attr\_accessor :session in the  
ActionController::Base file.

But, it doesn’t explain how my test rails app was able to use an action  
called session. Also, I tried to use other actions such as headers and  
response in my current app and they both worked.

Finally, even if I do avoid using session as an action, the thread  
handling the request for [http://localhost:3000/schedules/session](http://localhost:3000/schedules/session) still  
gets stuck in some kind of infinite loop when requested.

It just seems that somehow I’ve exposed a bug in rails and I’d like to  
find out what it is.
