Forum: Ruby on Rails Strange: Can't use action 'session'

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
01aceec3f1d2a1d0ff189de901e10f22?d=identicon&s=25 Michael Lee (dreamwave)
on 2005-11-24 09:40
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:

<h1>Session</h1>

<p><%= @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.
54532f023496410e0d7b1add5561ba45?d=identicon&s=25 purestorm (Guest)
on 2005-11-24 09:54
(Received via mailing list)
Am 24.11.2005 um 09:40 schrieb Michael Lee:

> 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 Holtgrewe
8de11f47e38b4ca190aa80706f7f4f52?d=identicon&s=25 morus.walter.ml (Guest)
on 2005-11-24 10:22
(Received via mailing list)
On Thu, 24 Nov 2005 09:40:00 +0100
Michael Lee <musicalpath@yahoo.com> 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
01aceec3f1d2a1d0ff189de901e10f22?d=identicon&s=25 Michael Lee (dreamwave)
on 2005-11-24 17:10
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.
This topic is locked and can not be replied to.