I'm creating a gem to create an around_filter
on my ApplicationController
in all projects that the gem is in. This is my first gem and I'm having a few concerns.
I included rails
as a dependency in the gemspec file, but how would I reference anything in rails?
Would I do something like require 'rails'
at the top of my file, then do something like
Rails::Path::To::ApplicationController
? I understand I could do something like:
Module MyGem
def self.included(klass)
klass.class_eval do
around_filter do |controller, action|
#insert code here
end
end
end
end
Then, in my Rails app I would include it in my Rails ApplicationController, but I don't want to have to include it. Of course, I might have to do some additional config for even that to work, but that is the gist of my crux. How would I reference ApplicationController
in my gem? Do I just assume I have Rails
since it is a dependency now and I should be able to freely call upon it in my ruby files?