How do you access sessions and cookies from within a Rails gem or lib?
Im trying to create what will eventually be a rails gem (right now I have the files within the /lib directory) and I need to be able to read/write to and from cookies and sessions. My methods will be called from within either the controller or views, so access to the cookies and sessions SHOULD be possible from within my gem but I cant figure out how to do it.
Ive tried extending ActionController to include my module as well as includi开发者_如何学Cng ActionController inside my module and nothing works. It could be the way Im running my tests since I feel like I have more success when trying to access my module and classes from within console.
Does anyone have any examples of accessing cookies and sessions from within gems/plugins etc?
Thanks,
Josh
See session=env['rack.session']
in https://github.com/hassox/warden/blob/master/lib/warden/session_serializer.rb#L6.
精彩评论