I would like to allow anonymous access to my forums. I am using the Forem Gem and the Devise Gem. I have a before_filter in my ApplicationController that ensures users are logged in.
before_filter :authenticate_user!
In my own controllers I use skip_filter to allow anonymous access to actions but I do not know how to do this for the controllers in the Forem Gem.
I could move the before_filter statement from my ApplicationController into each of my own Controllers but I would rather not.
The best place for this would be a file inside your
app/controllersdirectory atforem/application_controller-decorator.rbthat contains this content:You would then need to include this file using lines like this in a file called
config/initiailizers/load_decorators.rb:This would allow you to specify other decorators as well, for any other class of Forem, if you so desired.
I stole this idea from Spree (which I work on full-time now), and I think it’s pretty solid. You can see the original implementation of it here.