Active_Model error in rails

2019-08-21 05:19发布

I went back to a rails project I was working on and the command "rails s" started to fail. The Terminal recommended that I run a bundle install. When I did I received the following message:

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

    rails (>= 0) ruby depends on
    activemodel (3.2.12) 

I have updated both ruby and rails. I've re-installed active model and restarted my terminal.

My gems file is very simple:

 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

4条回答
啃猪蹄的小仙女
2楼-- · 2019-08-21 05:45

Remove Gemfile.lock

and then bundle if not works then specify rails version in gemfile.

查看更多
淡お忘
3楼-- · 2019-08-21 05:53

have you tried running

gem update activemodel

or

bundle update
查看更多
做个烂人
4楼-- · 2019-08-21 05:58

Remove your Gemfile.lock and run

  • rm Gemfile.lock

    and

  • bundle install

查看更多
等我变得足够好
5楼-- · 2019-08-21 06:06

Bundler has attempted to install Rails 4 and associated gems, but you have some gems fixed at earlier incompatible versions. Either specify a 3.x.x version of Rails or remove the version requirements on your sass-rails and coffee-rails gems.

(I took your Gemfile into a sample application and attempted to run a bundle install--I didn't get the exact error you're seeing but an error of the same cause. Removing the version requirements on those gems solved the issue. Of course that may not be appropriate for your needs!)

查看更多
登录 后发表回答