0

嗨,我是开发 Rails 应用程序的新手,我有兴趣在我的电子商务网站上使用“spree”。

我正在从这个网站 http://guides.spreecommerce.com/getting_started.html大肆学习本教程

  1. 我按照上面的教程进行了全新安装。我使用 rails 1.9.3 和 mysql 数据库完成了“5.1 启动 Spree”部分。一切都很好,直到我注意到登录栏没有像教程那样出现。

  2. 我做了一些研究,导致我在 https://github.com/railsdog/deface/issues/12中找到了这个解决方案, 我从这篇文章中了解到,问题似乎来自使用时污损 gem 中的“错误” ruby 1.9.3 ,但问题没有出现在 1.9.2 中,所以我将我的 ruby​​ 版本更改为 1.9.2 进行尝试。

  3. 安装 ruby​​ 1.9.2 后,我安装了“spree”gem,我从“入门教程”重复了该项目(使用 mysql 数据库)以完成教程。

  4. 现在在第 4.4.2 部分,我输入“rake db:create”终端输出这个

    store$ rake db:create

    store_test 已经存在
    store_development 已经存在

  5. 当我尝试通过“rails g spree:site”生成狂欢网站时,终端给了我这个错误

store  rails g spree:site
          create  config/spree.yml /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.2/lib/generators/spree/site/site_generator.rb:16:in
    `block in config_spree_yml': undefined method `version' for
    Spree:Module (NoMethodError)    from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in
    `call'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:54:in
    `render'    from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in
    `block (2 levels) in invoke!'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in
    `open'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:63:in
    `block in invoke!'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `call'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb:114:in `invoke_with_conflict_check'    from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:61:in
    `invoke!'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions.rb:95:in
    `action'    from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/actions/create_file.rb:26:in
    `create_file'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.70.2/lib/generators/spree/site/site_generator.rb:15:in
    `config_spree_yml'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:in
    `run'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:118:in
    `invoke_task'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
    `block in invoke_all'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
    `each'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
    `map'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in
    `invoke_all'    from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:226:in
    `dispatch'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/base.rb:389:in
    `start'     from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.2/lib/rails/generators.rb:168:in
    `invoke'    from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.2/lib/strong textrails/commands/generate.rb:12:in `<top (required)>'  from
    /Usestrong textrs/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.2/lib/active_support/dependencies.rb:240:in
    `require'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.2/lib/active_support/dependencies.rb:240:in
    `block in require'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.2/lib/active_support/dependencies.rb:223:in
    `block in load_dependency'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.2/lib/active_support/dependencies.rb:640:in
    `new_constants_in'  from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.2/lib/active_support/dependencies.rb:223:in
    `load_dependency'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.2/lib/active_support/dependencies.rb:240:in
    `require'   from
    /Users/macbookpro/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.2/lib/rails/commands.rb:28:in
    `<top (required)>'  from script/rails:6:in `require'    from
    script/rails:6:in `<main>' 
  1. 我很困惑,因为我之前没有创建数据库(但它表明它存在)。现在我什至不能生成狂欢网站。我研究这个问题好几天了,还没有找到匹配的解决方案。这就是我的 Gemfile 的样子

    来源“http://rubygems.org”

    gem 'rails', '3.1.2'
    
    # Bundle edge Rails instead:
    # gem 'rails',     :git => 'git://github.com/rails/rails.git'
    
    gem 'mysql2'
    
    
    # Gems used only for assets and not required
    # in production environments by default. group :assets do   gem 'sass-rails',   '~> 3.1.5.rc.2'     gem 'coffee-rails', '~> 3.1.1'  
    gem 'uglifier', '>= 1.0.3' end
    
    gem 'jquery-rails'
    
    # To use ActiveModel has_secure_password
    # gem 'bcrypt-ruby', '~> 3.0.0'
    
    # Use unicorn as the web server
    # gem 'unicorn'
    
    # Deploy with Capistrano
    # gem 'capistrano'
    
    # To use debugger
    # gem 'ruby-debug19', :require => 'ruby-debug'
    
    group :test do   # Pretty printed test output   gem 'turn', '0.8.2',
    :require => false
    
    gem 'spree' , '0.70.2'
    
    end 
    
  2. 如果有人可以为我的问题提供一些指示或解决方案,我将不胜感激。我现在很迷茫,它肯定会让某人开心。(如果您需要有关我的 ruby​​ 环境的更多信息,请告诉我)

4

3 回答 3

1

截至今天(2012 年 12 月 2 日),当前与 ruby​​ 1.9.3 和 rails 3.2.9 兼容的 spree 版本是 spree -v '1.2.2"

http://spreecommerce.com/blog/2012/11

1.3 版将于 2012 年 12 月发布

我不是专家,但我认为您需要将 gemfile 更改为

gem 'spree', '1.2.2'
于 2012-12-02T19:17:54.393 回答
1

您是否开始使用新的 Rails 应用程序?这是我(昨天)在 Fedora 16 上使用 Ruby 1.9.2p290、Rails 3.1.1 所做的:

  1. 确保安装了 ImageMagick - 如果没有它,引导脚本将无法工作。

  2. 运行 rails new appname --database mysql

  3. cd 应用程序名称

  4. 将 gem、'spree'、'0.70.3' 添加到 Gemfile

  5. 运行捆绑

  6. 配置database.yml

  7. 运行 rake db: create - 忽略任何数据库存在错误

  8. 运行 rails generate spree:site - 忽略任何数据库存在错误

  9. 运行 rake db:bootstrap

应该是这样的。

于 2011-11-28T18:46:47.340 回答
1

刚刚意识到 - 你在 ":test" 组中有 "gem 'spree'..."。不好。不要乱用 Gemfile - 只需在最后添加 spree gem。

于 2011-11-28T18:50:51.313 回答