我想在我的Rails项目中使用symbolize gem(http://rubygems.org/gems/symbolize)。我添加了
gem 'symbolize', '4.2.0'
到我的Gemfile并运行bundle install
。如果我运行gem list --local
,我会看到已安装的宝石。
然而,当我实际尝试使用gem添加到ActiveRecord的方法时,我在运行时遇到错误。即,我有:
class WrittenEntry < ActiveRecord::Base
symbolize :entry_type, :in => [:blog, :vorfreude, :twitter], :i18n => false
end
引发:
/Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/dynamic_matchers.rb:50:in `method_missing': undefined method `symbolize' for #<Class:0x007ff7ee8ad570> (NoMethodError)
from /Users/haldimann/Projects/nikhaldimann.com/app/models/written_entry.rb:4:in `<class:WrittenEntry>'
from /Users/haldimann/Projects/nikhaldimann.com/app/models/written_entry.rb:1:in `<top (required)>'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:359:in `require_or_load'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:313:in `depend_on'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:225:in `require_dependency'
from /Users/haldimann/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.9/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
...
看来,symbolize gem实际上从未实际加载过。我可能会遗漏一些明显的想法?