在一起设置狂欢和炼油厂时,“未初始化的常量用户”

时间:2012-09-05 14:23:27

标签: spree refinerycms

我一直在努力建立狂欢和炼油厂以及以下目的: 同时使用相同的身份验证系统

根据github项目和随后进入狂欢主分支......这应该顺利进行(第一回答评论中提供的链接)

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

首先,环境:

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

其次,按照guide

中的说明安装炼油厂
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

最后,安装狂欢(没有身份验证)

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

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

感谢您的帮助! 马努

2 个答案:

答案 0 :(得分:2)

终于搞定了,看起来很简单.... mmmfff

所以我只需要指定&#34; Refinery :: User&#34; (不仅仅是&#34;用户&#34;)来解决有关用户的问题。

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] 

如此合乎逻辑:)

答案 1 :(得分:0)

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

> 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]

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