我遵循的步骤
安装了Gem paper_trail 1.4.0
ruby script / generate paper_trail
rake db:migrate
将has_paper_trail添加到您要跟踪我在插件中创建的模型的模型中。
的
class AlphenaPaygrade < ActiveRecord::Base
has_paper_trail
validates_presence_of :name
validates_uniqueness_of :name
end
我收到以下错误:
/home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in `method_missing': undefined local variable or method `has_paper_trail' for #<Class:0x7f3beaa90f60> (NameError)
from /home/rank/rails/rank_fedena/app/models/user.rb:20
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in `load_file'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:379:in `load_file'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:259:in `require_or_load'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:425:in `load_missing_constant'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
from /home/rank/rails/rank_fedena/vendor/plugins/fedena_bigbluebutton/lib/fedena_bigbluebutton.rb:22
from /home/rank/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /home/rank/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /home/rank/rails/rank_fedena/vendor/plugins/fedena_bigbluebutton/init.rb:17:in `evaluate_init_rb'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/rails/plugin.rb:158:in `evaluate_init_rb'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/rails/plugin.rb:154:in `evaluate_init_rb'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/rails/plugin.rb:48:in `load'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/rails/plugin/loader.rb:38:in `load_plugins'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/rails/plugin/loader.rb:37:in `each'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/rails/plugin/loader.rb:37:in `load_plugins'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/initializer.rb:369:in `load_plugins'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/initializer.rb:165:in `process'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
from /home/rank/rails/rank_fedena/config/environment.rb:20
from /home/rank/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /home/rank/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
from /home/rank/.rvm/gems/ruby-1.8.7-p374/gems/rails-2.3.5/lib/commands/server.rb:84
from /home/rank/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /home/rank/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from script/server:3
有人可以帮我整合一下吗? 我过去2天无法整合,请帮我解决这个问题。
答案 0 :(得分:1)
在您的vendor / plugins / plugin / config / custom_environment.rb
中添加此代码Rails :: Initializer.run do | config |
config.gem&#39; paper_trail&#39;,:version =&gt; &#39;&〜GT; 1.4.0&#39;
端
在rake文件中编写rake任务..
命名空间:插件名称 desc&#34;安装模块&#34; 任务:安装做
if File.exists?("#{Rails.root}/config/environment.rb")
src = File.read("#{Rails.root}/vendor/plugins/plugin/config/custom_environment.rb")
File.open("#{Rails.root}/config/environment.rb", "w") do |file|
file.puts(src)
end
端 结束 端
安装你的插件然后它会正常工作.....