Strange: Can't use action 'session'

Visiting the url:
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.

Am 24.11.2005 um 09:40 schrieb Michael L.:

Visiting the url:
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.

On Thu, 24 Nov 2005 09:40:00 +0100
Michael L. [email protected] wrote:

Visiting the url:
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

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 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.