Rails 3 Gem Include
开发者_运维知识库I have made this gem: https://github.com/RLovelett/feedzirra-rails
I want to be able to include it like: gem "feedzirra-rails", :git => "git://github.com/RLovelett/feedzirra-rails.git", :branch => "feedzirra-rails"
However, Rails does not seem to be extending ActiveRecord::Base automatically. Though, if I call require "feedzirra_rails"
inside of a model that uses acts_as_feed
everything is fine.
Basically, I don't want to have to call require. I just want acts_as_feed
available to all models automatically.
Suggestions?
You need to add a railtie to the gem. This will make it load automatically when you include the gem in your Gemfile. Make sure you require the railtie in lib/feedzirra.rb
http://api.rubyonrails.org/classes/Rails/Railtie.html
精彩评论