gpt4 book ai didi

ruby-on-rails - ActiveRecord::Migration 的未定义方法 `check_pending!'(Rails 教程)

转载 作者:数据小太阳 更新时间:2023-10-29 07:52:53 24 4
gpt4 key购买 nike

我的 sample_app\spec\requests\user_pages_spec.rb 文件:

 require 'spec_helper'

describe "User pages" do

subject { page }

describe "signup page" do
before { visit signup_path }

it { should have_content('Sign up') }
it { should have_title(full_title('Sign up')) }
end
end

测试后我得到:

No DRb server is running. Running in local process instead ...
-- check_pending!()
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:465:in `block in method_missing': undefined method `check_pending!' for #<ActiveRecord::Migration:0x4adcf18> (NoMethodError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `block in say_with_time'

最佳答案

check_pending!() 它是 Rails 4 中 ActiveRecord::Migration 的一种方法,在阅读错误时,发现您当前的 Rails 版本是 3.2,因此该方法将不起作用,如果您将 Spork 与 RSpec 一起使用你会发现 Spork 更改了你的 spec/spec_helper.rb 文件并添加了几行包括这一行:

 ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

如果你想继续你的测试而不检查是否有任何迁移仍在运行,你所要做的就是评论这一行并且你的测试将起作用,如果你没有使用Spork,仍然建议你打开spec/spec_helper.rb 并查看代码。

关于ruby-on-rails - ActiveRecord::Migration 的未定义方法 `check_pending!'(Rails 教程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21512491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com