Here is my gem: https://github.com/DerNalia/deep_cloning
这是我的宝石:https://github.com/DerNalia/deep_cloning
and this is how I include it in my gemfile:
这就是我在gemfile中包含它的方式:
gem "deep_cloning", :git => "git://github.com/DerNalia/deep_cloning.git"
The line that the following error is on is this:
以下错误所在的行是:
ActiveRecord::Base.extend(DeepCloning)
link to source file: https://github.com/DerNalia/deep_cloning/blob/master/lib/deep_cloning.rb
链接到源文件:https://github.com/DerNalia/deep_cloning/blob/master/lib/deep_cloning.rb
... so.. maybe I'm extending ActiveRecord::Base
wrong?
...所以..也许我正在扩展ActiveRecord :: Base错误?
% bundle exec script/server -p3001
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3001
/Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant ActiveRecord (NameError)
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `rake_original_const_missing'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/bundler/gems/deep_cloning-4d4df89848a4/lib/deep_cloning.rb:102
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `require'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /Users/me/Work/GravityLabs/myproject/config/environment.rb:68
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/rails-2.3.8/lib/initializer.rb:111:in `run'
from /Users/me/Work/GravityLabs/myproject/config/environment.rb:16
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
from /Users/me/Work/GravityLabs/myproject/config.ru:3
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/rack-1.1.3/lib/rack/builder.rb:46:in `instance_eval'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/rack-1.1.3/lib/rack/builder.rb:46:in `initialize'
from /Users/me/Work/GravityLabs/myproject/config.ru:1:in `new'
from /Users/me/Work/GravityLabs/myproject/config.ru:1
from script/server:3:in `eval'
from /Users/me/.rvm/gems/ruby-1.8.7-p352@myproject/gems/rails-2.3.8/lib/commands/server.rb:78
from script/server:3:in `require'
from script/server:3
1 个解决方案
#1
1
You should probably try require 'activerecord'
in your gem.
您应该尝试在gem中使用'activerecord'。
Regarding extend
and include
:
关于延伸和包括:
module M
def a
"hello"
end
end
MyClass1.extend M
MyClass1.a #=> "hello"
MyClass.new.a #=> NoMethodError
MyClass2.send :include, M
MyClass2.a #=> NoMethodError
MyClass2.new.a #=> "hello"
#1
1
You should probably try require 'activerecord'
in your gem.
您应该尝试在gem中使用'activerecord'。
Regarding extend
and include
:
关于延伸和包括:
module M
def a
"hello"
end
end
MyClass1.extend M
MyClass1.a #=> "hello"
MyClass.new.a #=> NoMethodError
MyClass2.send :include, M
MyClass2.a #=> NoMethodError
MyClass2.new.a #=> "hello"