2

我一直在尝试建立狂欢和炼油厂,其目的如下: 对两者使用相同的身份验证系统

根据 github 项目和随后拉入 spree master 分支......这应该会顺利进行(链接在第一个答案的评论中可用)

我努力尝试,但我无法摆脱“未初始化的常量用户”错误。我将尝试描述能够复制错误的所有必要步骤。

首先,环境:

gem install rails
rails new spreefinery
cd spreefinery

# resolve a dependency on which bundler fails
sed "s/'jquery-rails'/'jquery-rails', '~>2.0.0'/g" -i Gemfile 

echo "# adding custom gems for both spree and refinery
gem 'spree', :git => 'git://github.com/spree/spree.git', :branch => '1-2-stable'
gem 'spree_usa_epay'
gem 'spree_skrill'
gem 'refinerycms', :git => 'git://github.com/refinery/refinerycms.git', :branch => '2-0-stable'" >> Gemfile

bundle install

其次,按照指南中的说明安装炼油厂

rails generate refinery:cms --fresh-installation

带有分页补丁

echo "#Refinery uses the will_paginate gem for pagination, 
# while Spree uses Kaminari.... This fix makes both happy

if defined?(WillPaginate)
  module WillPaginate
    module ActiveRecord
      module RelationMethods
        alias_method :per, :per_page
        alias_method :num_pages, :total_pages
      end
    end 
  end
end" > config/initializers/spreefinery.rb

最终,安装 spree(无需身份验证)

bundle exec spree install --git=git://github.com/spree/spree.git --branch=1-2-stable

# use default config except for authentification :
  Would you like to install the default gateways? (yes/no) [yes] 
  Would you like to install the default authentication system? (yes/no) [yes] no
  What is the name of the class representing users within your application? [User] 
  Would you like to run the migrations? (yes/no) [yes] 
  Would you like to load the seed data? (yes/no) [yes] 
  Would you like to load the sample data? (yes/no) [yes] 

最后一个命令运行为:

 gemfile  spree
 gemfile  spree_usa_epay
 gemfile  spree_skrill
     run  bundle install from "."
  create  config/initializers/spree.rb
  create  config/spree.yml
  remove  public/index.html
  append  public/robots.txt
  create  app/assets/javascripts/store
  create  app/assets/javascripts/admin
  create  app/assets/stylesheets/store
  create  app/assets/stylesheets/admin
  create  app/assets/images/store
  create  app/assets/images/admin
  create  app/assets/javascripts/store/all.js
  create  app/assets/javascripts/admin/all.js
  create  app/assets/stylesheets/store/all.css
  create  app/assets/stylesheets/admin/all.css
  create  app/overrides
  append  config/environment.rb
  append  db/seeds.rb
 copying  migrations
creating  database
 running  migrations
 loading  seed data
    rake  db:seed 
rake aborted!
uninitialized constant User

Tasks: TOP => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)
     loading  sample data
      insert  config/routes.rb
**************************************************
We added the following line to your application's config/routes.rb file:

mount Spree::Core::Engine, :at => '/'
**************************************************
Spree has been installed successfully. You're all ready to go!

Enjoy!

您可以在 db:seed 步骤中看到错误。

Rails 服务器或 rake db:migrate 再次出现相同的错误。这是完整的回溯:

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant User
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/activesupport-3.2.8/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/core/lib/spree/core.rb:52:in `user_class'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/promo/app/models/spree/promotion/rules/user.rb:7:in `<class:User>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/promo/app/models/spree/promotion/rules/user.rb:4:in `<module:Rules>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/promo/app/models/spree/promotion/rules/user.rb:3:in `<class:Promotion>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/promo/app/models/spree/promotion/rules/user.rb:2:in `<module:Spree>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/promo/app/models/spree/promotion/rules/user.rb:1:in `<top (required)>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bundler/gems/spree-dbb0c56a60a9/promo/lib/spree/promo/engine.rb:44:in `block in <class:Engine>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/emb/Documents/envs/spreefinery/config/environment.rb:5:in `<top (required)>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/application.rb:103:in `require_environment!'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/gems/railties-3.2.8/lib/rails/application.rb:295:in `block (2 levels) in initialize_tasks'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/emb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/emb/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `<main>'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bin/ruby_noexec_wrapper:14:in `eval'
/Users/emb/.rvm/gems/ruby-1.9.3-p194@spreefinery/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:migrate => environment

在这一点上,我需要一些帮助。我发现一些关于这个错误的帖子说明模型用户可能不存在......但是炼油厂明确声明了一个用户类......所以我有点困惑。

谢谢你的帮助 !马努

4

2 回答 2

2

终于明白了,看起来很简单.... mmmfff

所以我只需要为关于用户的问题指定“Refinery::User”(而不仅仅是“User”)。

Would you like to install the default gateways? (yes/no) [yes] 
Would you like to install the default authentication system? (yes/no) [yes] no
What is the name of the class representing users ...? [User] **Refinery::User**
Would you like to run the migrations? (yes/no) [yes] 
Would you like to load the seed data? (yes/no) [yes] 
Would you like to load the sample data? (yes/no) [yes] 

如此合乎逻辑:)

于 2012-09-12T19:55:21.907 回答
0

您正在尝试安装 spree 并运行标准迁移,但我可以从您的条目中看到,您已明确声明不要安装 spree 附带的默认身份验证系统(就像炼油厂一样基于设计)。因此,在用户模型上运行的一些迁移失败了。

> bundle exec spree install --git=git://github.com/spree/spree.git
> --branch=1-2-stable
> 
    > use default config except for authentification :   Would you like to install the default gateways? (yes/no) [yes]    Would you like to
    > install the default authentication system? (yes/no) [yes] no   What is
    > the name of the class representing users within your application?
    > [User]    Would you like to run the migrations? (yes/no) [yes]   
    > Would you like to load the seed data? (yes/no) [yes]    Would you like
    > to load the sample data? (yes/no) [yes]

如果您尝试再次安装,但这次对“您要安装默认身份验证系统吗?”说“是”。那么它应该可以工作。本周我一直在研究一个类似的系统,并且运行良好。您将在您的数据库中获得两个命名空间的用户数据库表,但如果您希望两个系统共享一个身份验证系统,那么我认为您正在进行一些工作并且标准安装程序将不适用。

于 2012-09-07T08:47:40.817 回答