gpt4 book ai didi

mongodb - 如何正确配置 rails 4 和 mongoid ?

转载 作者:IT老高 更新时间:2023-10-28 13:30:10 26 4
gpt4 key购买 nike

我很难让 mongo 和 rails 4 正常运行,目前我的 gemfile 看起来像

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
gem "zeus", "~> 0.13.3"
gem "thin", "~> 1.6.0"
gem "pry", "~> 0.9.12.2"
gem "rspec-rails", "~> 2.14.0"
gem "font-awesome-rails"
gem "haml", "~> 4.0.3"
gem "skrollr-rails", "~> 0.6.12"
gem "zurb-foundation", "~> 4.3.2"
gem 'rails_12factor', group: :production
gem "bourbon", "~> 3.1.8"
gem "gon", "~> 4.1.1"
gem "d3-rails"
gem 'underscore-rails'
gem 'mongoid', github: 'mongoid/mongoid'

group :doc do
gem 'sdoc', require: false
end

我的 mongoid.yml 看起来像

development:
sessions:
default:
database: mongoid
hosts:
- localhost:27017
options:
options:
production:
sessions:
default:
url: <%= ENV['MONGOHQ_URL'] %>
options:
consistency: :strong
max_retries: 1
retry_interval: 0

我收到以下错误,

[jd@mbp ~/Dropbox/honeybadgerconsulting/appcellerator/maturity_assessment (master *)]$ rails s
/Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- rack/mongoid (LoadError)
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/bundler/gems/mongoid-9296c9372579/lib/mongoid.rb:33:in `<top (required)>'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/jd/Dropbox/honeybadgerconsulting/appcellerator/maturity_assessment/config/application.rb:10:in `<top (required)>'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /Users/jd/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

当我尝试运行 rails 服务器时。

我已经定义了一个模型,只是为了测试 mongo 是否正常工作

class Project
include Mongoid::Document
field :name, type: String
field :status, type: String

end

我的 application.rb 有以下我在看似不完整的互联网教程领域看到的添加内容。

require File.expand_path('../boot', __FILE__)

require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

任何关于采取什么方向的帮助将不胜感激。

最佳答案

问题解决了。是一个错误 https://github.com/mongoid/mongoid/pull/3368 ,现在可以正常工作了。

关于mongodb - 如何正确配置 rails 4 和 mongoid ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19803043/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com