ActiveRecord :: StatementInvalid:PG ::错误:错误:列contents.app_id不存在

时间:2014-03-27 08:46:43

标签: ruby-on-rails activerecord ruby-on-rails-3.1 pg

从3.0.20升级rails后出现问题=> 3.1.12。当我运行单元测试时,一些测试通过,但我得到8个错误和18个失败。错误是column doesn't exist

=============================================== =================================== 这是我的一个错误:

Error: test_the_results_of_searching_content_model_by_keyword_is_two(SearchRecordsTest)
  ActiveRecord::StatementInvalid: PG::Error: ERROR:  column contents.app_id does not exist
  LINE 1: ...%') OR "contents"."copyrighter" LIKE '%Food%') OR "contents"...
                                                               ^
  : SELECT COUNT(*) FROM "contents"  WHERE (((((((("contents"."content_id_token" LIKE '%Food%' OR "contents"."name" LIKE '%Food%') OR "contents"."description" LIKE '%Food%') OR "contents"."copyrighter" LIKE '%Food%') OR "contents"."app_id" IN (SELECT "apps"."id" FROM "apps"  WHERE "apps"."app_id_token" LIKE '%Food%')) OR "contents"."app_id" IN (SELECT "apps"."id" FROM "apps"  WHERE "apps"."name" LIKE '%Food%')) OR "contents"."author_id" IN (SELECT "authors"."id" FROM "authors"  WHERE "authors"."name" LIKE '%FoodFood')) OR "contents"."author_id" IN (SELECT "authors"."id" FROM "authors"  WHERE "authors"."name_kana" LIKE '%Food%')))
test/unit/search_records_test.rb:26:in `check_results'
test/unit/search_records_test.rb:53:in `block in search_and_check_results_common_process'
test/unit/search_records_test.rb:47:in `each'
test/unit/search_records_test.rb:47:in `search_and_check_results_common_process'
test/unit/search_records_test.rb:79:in `block in <class:SearchRecordsTest>'

这是测试代码。

test 'the results of searching content model  by keyword is two' do
    expected_records  = [:content12, :content13]
    search_text       = 'Food'
    with_column       = { content: { type: 0 } }

    search_and_check_results_common_process(Content, search_text, with_column, expected_records)
  end

0 个答案:

没有答案