私はレールでmongoDBをテストしようとしています.私は両方ともかなり新しいです。
まず、mongoDB がインストールされ、Windows サービスとして動作します。
さて、これは私が単純なアプリを作成するために行ったステップです:
私はこれでアプリを作成しました:
rails new MongoOnRailsBlog -O -J -T
次に、gemfile を変更すると、次のようになります。
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'mongoid'
gem 'bson_ext'
gem 'will_paginate'
gem 'devise'
gem 'haml'
gem 'haml-rails', :group => :development
gem 'hpricot', :group => :development
gem 'formtastic'
gem 'jquery-rails'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
application.rb を変更して、いくつかのジェネレーターを追加しました。
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module MongoOnRailsBlog
class Application < Rails::Application
# Configure generators
config.generators do |g|
g.orm :mongoid
g.template_engine :haml
end
end
end
次に、mongoID 構成を生成しようとすると、次のようになります。
rails generate mongoid:config
「ファイルを読み込めません」エラーが発生しました
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- mongoid/version (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/devise-1.5.4/lib/devise/rails.rb:34:in `block in <class:Engine>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) ineach_strongly_connected_component'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from E:/Dev/Projects/MongoOnRailsBlog/config/environment.rb:5:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:45:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
私はそれがMongoIDの良いバージョンに関係していると推測していますが、どこを確認すればよいのか、どのようにして良いバージョンをロードしているのかわかりません...
どこを見るべきかについて何か提案はありますか?
感謝。