我是Spree和Rails的新手并且一直关注开发人员指南(http://guides.spreecommerce.com/developer/extensions_tutorial.html) 关于狂欢商业建立一个新的扩展,但没有成功。
当我在我的Spree扩展导演中执行以下操作时,
rails g migration add_sale_price_to_spree_variants sale_price:decimal
我得到了
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/acts_as_list-0.2.0/lib/acts
_as_list.rb:18:in `insert': uninitialized constant ActiveRecord::Base (NameError
)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/acts_as_list-0
.2.0/lib/acts_as_list.rb:24:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:64:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:64:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/spree_core-2.0
.4/lib/spree/core.rb:3:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:116:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:116:in `rescue in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:122:in `require'
from C:/Sites/spree_layered_pricing/lib/spree_layered_pricing/engine.rb:
3:in `<class:Engine>'
from C:/Sites/spree_layered_pricing/lib/spree_layered_pricing/engine.rb:
2:in `<module:SpreeLayeredPricing>'
from C:/Sites/spree_layered_pricing/lib/spree_layered_pricing/engine.rb:
1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:112:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:112:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1
4/lib/rails/engine/commands.rb:13:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:64:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:64:in `require'
from script/rails:7:in `<main>'
有解决方法吗?我错过了什么?
答案 0 :(得分:0)
在您所指的文档中,只需吹一下迁移示例,他们就说
TODO:让上面的生成器实际上在扩展目录中工作
您是否尝试使用其他名称,然后使用他们提供的代码?
class AddSalePriceToSpreeVariants < ActiveRecord::Migration
def change
add_column :spree_variants, :sale_price, :decimal, :precision => 8, :scale => 2
end
end