我正在尝试在 EngineYard 上部署我的应用程序。就在assets:precompile
它作为迁移的一部分检查数据库更改之前。这导致我失败,因为我在应用程序启动过程中预加载了一些选择框值:
STANDARD_ATTRIBUTES = {}
for standard in Standard.all
begin
STANDARD_ATTRIBUTES[standard.id] = {}
valuehash = JSON.parse(IO.read(standard.json_file_name))
for key,values in valuehash
STANDARD_ATTRIBUTES[standard.id][key.to_sym] = values
end
rescue
message = "Could not locate JSON file for the #{standard.name} standard. Perhaps you need to run 'bundle exec rake:monthly collect_unique_values_from_standard name='#{standard.name}'?"
puts message
ActiveRecord::Base.logger.error message
end
end
对 Standard.all 的第一次调用导致了一个问题,因为该表尚未创建。我怎样才能解决这个问题?这里有一个答案,但这对我来说是不可理解的。