对于 mongoid 命令,Rails g 失败

编程入门 行业动态 更新时间:2024-10-24 18:22:02
本文介绍了对于 mongoid 命令,Rails g 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 ruby​​-1.9.2 和以下命令从 rails 3.2 应用程序初始化 mongoid:

I am trying to initialise mongoid from a rails 3.2 application using ruby-1.9.2 with the following command:

rails g mongoid:config

当我发出命令时,出现以下错误:

When I issue the command, I get the following error:

/Users/paulcowan/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:143:inblock in replace_gem':railties 不是捆绑包的一部分.添加到宝石档案.(宝石::加载错误)来自/Users/paulcowan/.rvm/gems/ruby-1.9.2-p290/bin/rails:18:in'

/Users/paulcowan/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.18/lib/bundler/rubygems_integration.rb:143:in block in replace_gem': railties is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /Users/paulcowan/.rvm/gems/ruby-1.9.2-p290/bin/rails:18:in'

我的 gem 文件如下所示:

My gem file looks like this:

source 'rubygems' gem 'rails', '3.2.3' group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' # structures gem 'json', '~> 1.6.3' gem 'rabl', '~> 0.5.1' # use thin instead of WEBrick gem 'thin' # MongoDB.. gem 'bson_ext' gem 'mongoid' gem "haml", ">= 3.1.4" gem "haml-rails", ">= 0.3.4", :group => :development gem "bootstrap-sass", ">= 2.0.1" gem 'inherited_resources' group :development, :test do gem 'guard' gem 'growl' gem 'rspec-rails', '2.8.1' gem 'webrat', '0.7.3' gem 'factory_girl_rails', '1.7.0' gem 'rdoc', '~> 3.12' gem "database_cleaner" gem "mongoid-rspec" gem "pry-rails", "~> 0.1.6" end group :test do gem 'jasminerice', :git => "github/bradphelan/jasminerice.git", :branch => 'master' gem 'guard-jasmine', :git => "github/netzpirat/guard-jasmine.git", :branch => 'master' gem 'capybara', '~> 1.1.2' gem 'fivemat' end

推荐答案

我在一个新的 Rails 3.2.3 项目和 Gemfile 之后遇到了各种打包程序/gem 问题.我能够通过删除 Gemfile.lock 并重新运行捆绑安装"来克服它.附上我所做的日志,其中包括删除 ActiveRecord.希望这会有所帮助.

I had various bundler/gem problems with a fresh Rails 3.2.3 project followed by your Gemfile. I was able to get past it by removing Gemfile.lock and rerunning 'bundle install'. The log of what I did is attached and it includes excising ActiveRecord. Hope that this helps.

$ ruby -v ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0] $ rails new free-11479-mongoid-rails-g $ cd free-11479-mongoid-rails-g Gemfile as per user $ bundle install You have requested: json ~> 1.6.3 The bundle currently has json locked at 1.7.1. Try running `bundle update json` $ bundle update json Bundler could not find compatible versions for gem "multi_json": In Gemfile: rabl (~> 0.5.1) ruby depends on multi_json (~> 1.0.3) ruby guard-jasmine (>= 0) ruby depends on multi_json (1.3.4) $ rm Gemfile.lock $ bundle install $ rails g mongoid:config create config/mongoid.yml --------- Assuming that you want to excise ActiveRecord... dereference ActiveRecord config/application.rb #config.active_record.whitelist_attributes = true config/environments/development.rb #config.active_record.mass_assignment_sanitizer = :strict #config.active_record.auto_explain_threshold_in_seconds = 0.5 config/environments/development.rb #config.active_record.mass_assignment_sanitizer = :strict test/test_helper.rb #fixtures :all $ rm database.yml config/application.rb #require 'rails/all' require "action_controller/railtie" require "action_mailer/railtie" require "active_resource/railtie" require "rails/test_unit/railtie" $ rake test # passes

更多推荐

对于 mongoid 命令,Rails g 失败

本文发布于:2023-10-29 03:30:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538595.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   mongoid   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!