我继续在程序中的任何地方随机获取ActiveRecord :: MissingAttributeError错误。我有乘客(30个实例)与nginx一起运行。我在开发中没有这个问题。当我删除缓存资金时,它在生产中工作正常。
这是错误消息:
ActiveRecord::MissingAttributeError (missing attribute: deposit_amount):
lib/econveyance_pro/accounting/bsoa.rb:96:in `collect_deposit'
lib/econveyance_pro/accounting/bsoa.rb:24:in `calculate'
app/controllers/accounting_controller.rb:213:in `calculate_buyer_file_accounting'
app/controllers/accounting_controller.rb:175:in `generate_accounting'
app/controllers/accounting_controller.rb:153:in `generate_accounting_and_save'
lib/econveyance_pro/document_manager.rb:18:in `temporary_tables_xml'
lib/econveyance_pro/document_manager.rb:17:in `each'
lib/econveyance_pro/document_manager.rb:17:in `temporary_tables_xml'
app/controllers/document_manager_controller.rb:40:in `xml'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/railz/application_spawner.rb:385:in `start_request_handler'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/railz/application_spawner.rb:343:in `handle_spawn_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/utils.rb:184:in `safe_fork'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/railz/application_spawner.rb:341:in `handle_spawn_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:163:in `start'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/railz/application_spawner.rb:209:in `start'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.2.8/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
deposit_amount确实存在于我的数据库中。
答案 0 :(得分:1)
您是否更改了数据库表架构? memcached对象可能正在使用旧模式,需要清除。
使用$ cache.flush_all刷新memcached,通过'telnet localhost 11211'向memcached发送“flush_all”,或者重新启动memcached。
答案 1 :(得分:0)
您的数据库中可能存在缺失属性,但您的架构和迁移中是否存在?
尝试自己通过sql查询访问它,然后在控制台中,如果你可以同时访问它,请检查你的控制器在sql中的拼写错误
答案 2 :(得分:0)
事情就是当我停止使用缓存资金时,这部分代码可以正常运行而不会出现问题。很快,当我启用缓存资金时,我得到了这个错误,我已经完成了几次查询。
当打开缓存资金时,我也会在程序的随机区域中针对不同属性收到此错误。
答案 3 :(得分:0)
我认为这可能是一个生产问题。当您在生产环境中启动应用程序时,它会在所有文件的应用程序内部进行缓存。你没有完全解释它,但我认为问题是因为你确实推出了迁移,也许没有重启服务器。
如果是这种情况,可能是因为您正在使用的缓存可能仍然具有对该属性的圆顶引用,该引用已经存在。 =)