SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about Ruby Syntax in Rails

    To extend sessions in my class I must do this in rails:

    Code:
    class ApplicationController < ActionController::Base
    	model :user
    	before_filter :verify_user
    
    	def verify_user
    ::ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_expires => 1.hour.from_now)
    
    		...
    	end
    end
    I am new to Ruby Also. Why must I use the :: operator to access ActionController? And doesnt rails have an instance of CgiRequest with @request? Why Cant I use that?

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does this work?

    Code:
    def verify_user
        session_options[:session_expire] = 1.hour.from_now
        
        # ... more code ...
        
    end
    I am new to Ruby Also. Why must I use the :: operator to access ActionController?
    I don't think you need the :: before ActionController. I don't think you even need the ActionController part either, because you are already inside the ActionController.

    And doesnt rails have an instance of CgiRequest with @request? Why Cant I use that?
    If it does have one, give it a try and see what happens, I've not used that before.

    Douglas
    Hello World


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •