I have a Rails engine (someone else's gem) that I am trying to modify by adding another gem as a dependency. I can't seem to f开发者_高级运维igure out how to get the engine to require the library. I've tried all sorts of different things, but I can't seem to get it to work.
My main app Gemfile I have the engine:
gem 'enginegem'
In the engine's gemspec I have:
s.add_dependency 'somethinggem', '~> 1.0'
In the Engine, there is a model that I am trying to modify by adding this acts_as_something
method:
class Page < ActiveRecord::Base
acts_as_something
end
And there is a controller that I am trying to modify:
class PagesController < ApplicationController
around_filter :do_something
def do_something
my_var = 'foobar'
Something.do_something_with my_var do
yield
end
end
end
What is the appropriate way to add this library as a dependency to the engine and have it require the library?
It'd help if you told us which gem you're trying to modify.
In most gems you will have a lib/enginegem.rb, there is probably the best place to require the gem:
require 'somethinggem'
EDIT: Although this answer didn't help the OP (see comments below), I'll keep it here, because it may help others.
EDIT 2: Everybody who is trying to create an engine should take a look at devise's code. If you want a more didactic approach, try Crafting Rails Applications book from Jose Valim. In fact, if you're serious with this engine, you should do both.
精彩评论