0

我是 Spree 和 Rails 的新手,一直在遵循关于 spree commerce 的开发人员指南 ( 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>'

有没有解决的办法?我错过了什么?

4

1 回答 1

0

他们说,在您所指的文档中,只需吹掉迁移示例

TODO:使上面的生成器实际上在扩展目录中工作

您是否尝试过使用不同的名称,然后使用他们提供的代码?

class AddSalePriceToSpreeVariants < ActiveRecord::Migration
  def change
    add_column :spree_variants, :sale_price, :decimal, :precision => 8, :scale => 2
  end
end 
于 2013-08-26T16:31:22.820 回答