我为branch
模型进行了迁移,将branch_name
更改为phone_contact
。然后我将代码更改为:
class ContactWorker
include Sidekiq::Worker
def perform(record, service_type = 'test', list_type = 'test')
phone_contact = PhoneContact.create(
client_id: record['ClientID'],
client_name: record['ClientName'],
branch_id: record['branchID'],
branch_name: record['branch'],
unit_id: record['UnitID'],
member_id: record['MemberID'],
first_name: record['FirstName'],
last_name: record['LastName'],
date_of_birth: record['DateofBirth'],
most_recent_join_date: record['ChangeDate'],
old_membership_type: record['OldMembershipType'],
membership_type: record['NewMembershipType'],
phone_number: record['HomePhone'],
email: record['EMailAddress'],
visits: record['ID__Visits'],
primary_language: record['PrimaryLanguage'],
call_type: record['CallType'],
list_id: "#{Time.new.strftime("%Y_%m_%d")}_#{service_type}_#{list_type}"
)
end
end
如您所见,branch
已不再列出。它明确指出branch_name:
。
所以我传入一个record
,这是一个包含所有上述属性的哈希给这个工人。无论哈希是什么样的,这都是我收到的错误:
" error_message" =>" PG :: UndefinedColumn:ERROR:column \" branch \"的 关系\" phone_contacts \"不存在\ nLINE 1:INSERT INTO \" phone_contacts \" (\"分支\",\" branch_id \",\" call_t ... \ n
^ \ n:INSERT INTO \" phone_contacts \" (\"分支\",\" branch_id \", " call_type \",\" client_id \",\" client_name \",\" created_at \", \" date_of_birth \",\" email \",\" first_name \",\" last_name \", \" list_id \",\" member_id \",\" membership_type \", \" most_recent_join_date \",\" old_membership_type \",\" phone_number \", \" primary_language \",\" unit_id \",\" updated_at \",\"访问\")价值观 ($ 1,$ 2,$ 3,$ 4,$ 5,$ 6,$ 7,$ 8,$ 9,$ 10,$ 11,$ 12,$ 13,$ 14,$ 15, 16美元,17美元,18美元,19美元,20美元)退回\" id \"", " error_class" = GT;" ActiveRecord的:: StatementInvalid"
错误更改为此而没有更改代码 - 我刚收到unknown attribute: branch_name
错误。
可能导致这种情况的原因是什么?我的迁移运行正常,当我查看我的数据库时,我看到branch_name,如果我使用Rails控制台并手动完成我的代码所经历的步骤,它可以正常工作。它只在我使用Sidekiq
时失败。我使用的是Ruby 2.0.0和Rails 4.0.0。
答案 0 :(得分:2)
我的观点是架构是缓存的。您是否尝试重新启动所有工作人员?