My gem works fine with Rails 2.3 (using Bundler) but I cannot get it loaded in Rails 3.
my_app/Gemfile:
gem 'mygem', '>= 0.1.0', :path => '../mygem/'
I know that it is found because I managed to get it "working" once.
I've read between the lines of many blog posts and rails tickets that rails/init.rb
is deprecated and a toplevel init.rb
should be used that requires the main lib file. However, none of them gets executed unless I require 'my_gem'
explicitly in my Rails app. This is how it looks like at the moment:
mygem/init.rb`:
require File.join(File.dirname(__FILE__), 'lib', 'my_gem')
raise StandardError, "derailed!"
mygem/lib/my_gem:
require 'my_gem/template_handler'
raise Standa开发者_开发知识库rdError, "derailed!"
module MyGem
class Railtie < Rails::Railtie
raise StandardError, "derailed!"
initializer "template handler registration" do
raise StandardError, "derailed!"
ActionView::Template.register_template_handler :act, TemplateHandler
end
end
end
ActionView::Template.register_template_handler :act, TemplateHandler
I cluttered everything with raise statements... the fact that none of them is raised makes me think that all my attempts to register my template handler have been in vain... ;)
I am running out of ideas to get my gem loaded. my_gem/lib
is in the $LOAD_PATH
, everything seems to be fine.
精彩评论