rails中的Active_Model错误

我回到了我正在处理的rails项目,命令“rails s”开始失败。 终端建议我运行捆绑安装。 当我这样做时,我收到以下消息:

Bundler could not find compatible versions for gem "activemodel": In Gemfile: protected_attributes (>= 0) ruby depends on activemodel (= 4.0.0.beta) ruby rails (>= 0) ruby depends on activemodel (3.2.12) 

我已经更新了ruby和rails。 我重新安装了活动模型并重新启动了我的终端。

我的gems文件非常简单:

  gem 'rails' gem 'jquery-rails' gem 'devise' gem 'simple_form' gem 'protected_attributes' group :production do gem 'pg' end group :development, :test do gem 'sqlite3' end group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'bootstrap-sass', '~> 2.2.2.0' gem 'bootstrap' end 

删除你的Gemfile.lock并运行

  • rm Gemfile.lock

  • 捆绑安装

删除Gemfile.lock

然后捆绑,如果不起作用,然后在gemfile中指定rails版本。

你试过跑吗?

 gem update activemodel 

要么

 bundle update 

Bundler已经尝试安装Rails 4和相关的gem,但是你在早期的不兼容版本中修复了一些gem。 指定3.xx版本的Rails或删除sass-railscoffee-rails gems的版本要求。

(我把你的Gemfile带到了一个示例应用程序并试图运行一个bundle install – 我没有得到你看到的确切错误,但出现了同样原因的错误。删除这些gem上的版本要求解决了这个问题。当然可能不适合您的需求!)