我一直在尝试建立狂欢和炼油厂,其目的如下: 对两者使用相同的身份验证系统。
根据 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
在这一点上,我需要一些帮助。我发现一些关于这个错误的帖子说明模型用户可能不存在......但是炼油厂明确声明了一个用户类......所以我有点困惑。
谢谢你的帮助 !马努