Active_Model error in rails

可紊 提交于 2019-12-13 05:49:34

问题


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

回答1:


Remove your Gemfile.lock and run

  • rm Gemfile.lock

    and

  • bundle install




回答2:


Remove Gemfile.lock

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




回答3:


have you tried running

gem update activemodel

or

bundle update



回答4:


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!)



来源:https://stackoverflow.com/questions/19530913/active-model-error-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!