Forum: Ruby on Rails How to set session variable in plug-ins

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.
Berk d. D. (Guest)
on 2006-03-28 17:18
I'm working on a plug-in which has to manipulate some session varibles
Unfortunately I end up with "Symbol as array index" errors.

Probably the error occurs in a point that I never think about but here's
an abstract plug-in which generates the same error.

It fails in the line of assignment "session[:aaa_uid] = uid" with
"Symbol as array index" error.


module Legacy
  module Rails #:nodoc:
    module Test #:nodoc:

    def self.included(base)
      base.extend(ClassMethods)
    end

      module ClassMethods
        def uses_test_plug(options = {})
          class_eval do
            extend ::Legacy::Rails::Test::InstanceMethods
          end

          before_filter do |controller|
            set_aaa_uid("jdoe")
          end
        end
      end

      module InstanceMethods
        def set_aaa_uid(uid)
          session[:aaa_uid] = uid
        end
      end

      module SingletonMethods
      end

    end
  end
end

ActionController::Base.class_eval do
  include ::Legacy::Rails::Test
end
This topic is locked and can not be replied to.