spegoraro
spegoraro

Reputation: 96

How to access rails session variable from a module inside a gem

I'm creating a gem for rails that abstracts away bizarre third party API and having trouble with one item. Inside my gem I have a module with a class inside that needs to access rails' session variable. Is there any way I can do this easily or do I have to do it in the ApplicationController?

Cheers, Steve

Upvotes: 0

Views: 1954

Answers (1)

Ben Taitelbaum
Ben Taitelbaum

Reputation: 7403

Drawing inspiration from how the rails-footnotes gem sets itself up, I would suggest adding a mixin to ApplicationController::Base that adds a before_filter that grabs the session and stores it where your library can easily access it (like in the same class that will invoke whatever logic needs access to it).

Upvotes: 1

Related Questions