问题
I'm sure I miss some basic thing.
I had a correctly working app in dev environment. Than I had some modifications that I cant correctly explain (with the migrations and tried to insert seed_dump gem). Now every rake command drops an error:
C:\Programozas\Rails Apps\sorsveto>rake about
rake aborted!
undefined method `active_record' for #<Rails::Application::Configuration:0x3e482
98>
Tasks: TOP => about => environment
(See full trace by running task with --trace)
or
C:\Programozas\Rails Apps\sorsveto>rake db:migrate
rake aborted!
Don't know how to build task 'db:migrate'
(See full trace by running task with --trace)
There is my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.2'
gem 'bootstrap-sass', '2.0.0'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.5'
group :development do
gem 'sqlite3', '1.3.5'
gem 'annotate', '~> 2.4.1.beta'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test, :development do
gem 'rspec-rails', '~> 2.8.rc'
gem 'shoulda', '~> 3.0.1'
gem 'shoulda-context'
gem 'shoulda-matchers'
gem 'eventmachine', '1.0.0.rc.4'
gem 'listen', '0.4.7'
gem 'guard-livereload', '1.0.0'
gem 'guard-rspec', '0.5.5'
gem 'guard-spork', '0.3.2'
gem 'spork', '0.9.0'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
gem 'cucumber-rails', '1.2.1'
gem 'database_cleaner', '0.7.0'
end
# Test gems on Windows
group :test do
gem 'rb-fchange', '0.0.5'
gem 'rb-notifu', '0.0.4'
gem 'win32console', '1.3.0'
end
group :production do
gem 'pg', '0.12.2'
end
I can't figure out how to solve this. I tried to reinstall or install 0.8.7 and remove this (now I have version 0.9.2.2). I even tried to install 0.9.2. Many combinations (more than one at a time and run bundle exec rake XY) no success. I even tried to insert this into my gem file:
require 'rake/dsl_definition'
require 'rake'
Neither helped. Any ideas? All help mutch appriciated.
回答1:
It was so basic and annoying that I feel shame to even tell.
Somehow in my application.rb my this line:
require "active_record/railtie"
commented out. Removed the # and worked correctly.
回答2:
In my case, my Gemfile had somehow gotten deleted. Maybe because I aborted a rake action with CMD-C when it was half-way..
I fixed it with git co Gemfile
来源:https://stackoverflow.com/questions/11653584/rails-rake-aborted-undefined-method-active-record