问:
marshal data too short
My application requires to keep large data objects in session. There are like 3-4 data objects each created by parsing a csv containing 150 X 20 cells having strings of 3-4 characters.
My application shows this error- "marshal data too short".
I tried this-

Deleting the old session table.

Deleting the old migration for session table.

Creating a new migration using rake db:sessions:create.

editing the migration manually, changing text: data to longtext: data.

running the migration using rake db:migrate.

other details of application--

In view "index.html.erb"- There is a link that makes ajax call to an action in controller, that action parses large csv file and makes an object out of it. this object is stored in session.

ERROR LOG

```<code>` ArgumentError in Scoring#index

Showing app/views/scoring/index.html.erb where line #4 raised:

marshal data too short

Extracted source (around line #4):

1:
2: <form id="myForm">
3:
4:   <%= link_to_remote "get csv file",
5:        :url      => { :action => 'show_static_1' },
6:        :update   => "static_score",
7:        :complete => "$('static_score').update(request.responseText)" %>

Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:168:in `load_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:61:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:28:in `[]'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:106:in `form_authenticity_token'
(eval):2:in `send'
(eval):2:in `form_authenticity_token'
app/views/scoring/index.html.erb:4:in `_run_erb_app47views47scoring47index46html46erb'

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:168:in `load_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:61:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:28:in `[]'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:106:in `form_authenticity_token'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:1065:in `options_for_ajax'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:449:in `remote_function'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:256:in `link_to_remote'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:265:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:262:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1250:in `render_for_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:945:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:in `default_render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1338:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:122:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:168:in `load_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:61:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:28:in `[]'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:106:in `form_authenticity_token'
(eval):2:in `send'
(eval):2:in `form_authenticity_token'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:1065:in `options_for_ajax'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:449:in `remote_function'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:256:in `link_to_remote'
/app/views/scoring/index.html.erb:4:in `_run_erb_app47views47scoring47index46html46erb'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:265:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:262:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1250:in `render_for_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:945:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:in `default_render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1338:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:122:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
</code>```

Request

Parameters:

None

Show session dump

Response

Headers:

```<code>{"Content-Type"=>"text/html",
 "Cache-Control"=>"no-cache"}
</code>```

`

答:
The previous solutions didn't work for me. What did work for me was to clear the session's cache with</p>

```<code>rake db:sessions:clear
</code>```

Title: marshal data too short

Body:
My application requires to keep large data objects in session. There are like 3-4 data objects each created by parsing a csv containing 150 X 20 cells having strings of 3-4 characters.
My application shows this error- "marshal data too short".
I tried this-

Deleting the old session table.

Deleting the old migration for session table.

Creating a new migration using rake db:sessions:create.

editing the migration manually, changing text: data to longtext: data.

running the migration using rake db:migrate.

other details of application--

In view "index.html.erb"- There is a link that makes ajax call to an action in controller, that action parses large csv file and makes an object out of it. this object is stored in session.

ERROR LOG

` ArgumentError in Scoring#index

Showing app/views/scoring/index.html.erb where line #4 raised:

marshal data too short

Extracted source (around line #4):

1:
2: <form id="myForm">
3:
4:   <%= link_to_remote "get csv file",
5:        :url      => { :action => 'show_static_1' },
6:        :update   => "static_score",
7:        :complete => "$('static_score').update(request.responseText)" %>

Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:168:in `load_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:61:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:28:in `[]'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:106:in `form_authenticity_token'
(eval):2:in `send'
(eval):2:in `form_authenticity_token'
app/views/scoring/index.html.erb:4:in `_run_erb_app47views47scoring47index46html46erb'

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:168:in `load_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:61:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:28:in `[]'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:106:in `form_authenticity_token'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:1065:in `options_for_ajax'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:449:in `remote_function'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:256:in `link_to_remote'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:265:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:262:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1250:in `render_for_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:945:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:in `default_render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1338:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:122:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `load'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:71:in `unmarshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:110:in `data'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:292:in `get_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1448:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/session_store.rb:288:in `get_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:168:in `load_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:62:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:61:in `load!'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:28:in `[]'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/request_forgery_protection.rb:106:in `form_authenticity_token'
(eval):2:in `send'
(eval):2:in `form_authenticity_token'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:1065:in `options_for_ajax'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:449:in `remote_function'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/prototype_helper.rb:256:in `link_to_remote'
/app/views/scoring/index.html.erb:4:in `_run_erb_app47views47scoring47index46html46erb'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:34:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:306:in `with_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/renderable.rb:30:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:205:in `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:265:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:348:in `_render_with_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/base.rb:262:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1250:in `render_for_file'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:945:in `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:in `default_render'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:1338:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:10:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in `_call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:122:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:114:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/reloader.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:108:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/static.rb:31:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/chunked.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:64:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/mongrel.rb:34:in `run'
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:111
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

Request

Parameters:

None

Show session dump

Response

Headers:

{"Content-Type"=>"text/html",
 "Cache-Control"=>"no-cache"}

`

Body:
The previous solutions didn't work for me. What did work for me was to clear the session's cache with

rake db:sessions:clear


来源: stackexchange

问:
Shorten string without cutting words in JavaScript
I'm not very good with string manipulation in JavaScript, and I was wondering how you would go about shortening a string without cutting any word off. I know how to use substring, but not indexOf or anything really well.

Say I had the following string:

```<code>text = "this is a long string I cant display"
</code>```

I want to trim it down to 10 characters, but if it doesn't end with a space, finish the word. I don't want the string variable to look like this:

"this is a long string I cant dis"

I want it to finish the word until a space occurs.

答:
KISS answer</p>
```<code>'this is a string'.split(' ').reduce((a, b) => (a+b).length < 10 ? a+' '+b : a);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm not very good with string manipulation in JavaScript, and I was wondering how you would go about shortening a string without cutting any word off. I know how to use substring, but not indexOf or anything really well.

Say I had the following string:

text = "this is a long string I cant display"

I want to trim it down to 10 characters, but if it doesn't end with a space, finish the word. I don't want the string variable to look like this:

"this is a long string I cant dis"

I want it to finish the word until a space occurs.

Body:
KISS answer

'this is a string'.split(' ').reduce((a, b) => (a+b).length < 10 ? a+' '+b : a);

ContentLicense: CC BY-SA 4.0


答:
I think you df.loc works as you expect it to work but you apply the mask on the full df. I would do this instead:

df_a_columns = df.loc[:,df.columns.str.contains("_a_")]
df.loc[:,df.columns.str.contains("_a_")] = df_a_columns.mask((df_a_columns < 1) | (df_a_columns > 5))
```

Title: In python, with pandas, change several columns at once and modify some values (of these columns) to fit a predefined range

Body:
After looking at SO, I (think I) could force some columns to become numeric and transform to missing values outside a predefined range. (I think the code is ok).

However, when I try the same with the real data, I'm receiving the following error
typeError: Invalid comparison between dtype=datetime64[ns] and int

The simulated data and code: (working)

#dataframe
df2 = pd.DataFrame({"var_1": [2,"a"], "var_2": [5,7], "var_3": [1,np.NaN], "other_1": [1,9]})
df2
#modify any variable with "var"
df2.loc[:,df2.columns.str.contains("var")] = df2.apply(pd.to_numeric, errors='coerce')
df2.loc[:,df2.columns.str.contains("var")] = df2.mask((df2 < 1) | (df2 > 5))
df2

The quasi-real dataset and the code (not working):

from numpy import nan
df = pd.DataFrame.from_dict(
{'aut_a_p1_r1': {105: 3, 194: 4, 93: 3, 297: 3, 131: 4}, 'aut_a_p1_r2': {105: 4.0, 194: 5.0, 93: 3.0, 297: 5.0, 131: 4.0}, 'aut_a_p1_r3': {105: 5.0, 194: 5.0, 93: 4.0, 297: 3.0, 131: 5.0}, 'aut_a_p1_r4': {105: 2, 194: 1, 93: 3, 297: 4, 131: 3}, 'aut_a_p1_r5': {105: 4, 194: 4, 93: 4, 297: 1, 131: 4}, 'aut_a_p1_r6': {105: 4, 194: 5, 93: 4, 297: 3, 131: 5}, 'aut_a_p1_r7': {105: 5, 194: 5, 93: 3, 297: 3, 131: 5}, 'aut_a_p1_r8': {105: 3, 194: 2, 93: 3, 297: 4, 131: 2}, 'aut_a_p1_r9': {105: 4, 194: 4, 93: -1.5, 297: 2, 131: 5}, 'aut_a_p1_r10': {105: 4, 194: 5, 93: -1.4, 297: 4, 131: 4}, 'aut_a_p1_r11': {105: 5, 194: 5, 93: 5, 297: 3, 131: 4}, 'aut_a_p1_r12': {105: 3.0, 194: 4.0, 93: 4.0, 297: 4.0, 131: 5.0}, 'aut_a_p1_r13': {105: 4, 194: 5, 93: 3, 297: 2, 131: 5}, 'aut_a_p1_r14': {105: 4, 194: 4, 93: 4, 297: 4, 131: 4}, 'aut_a_p1_r15': {105: 3.0, 194: 4.0, 93: 5.0, 297: 3.0, 131: 5.0}, 'aut_a_p2_r1': {105: 5, 194: 5, 93: 4, 297: 4, 131: 5}, 'aut_a_p2_r2': {105: 4, 194: 3, 93: 2, 297: 1, 131: 1}, 'aut_a_p2_r3': {105: 4, 194: 5, 93: 5, 297: 4, 131: 4}, 'aut_a_p2_r4': {105: 3, 194: 4, 93: 4, 297: 2, 131: 3}, 'aut_a_p2_r5': {105: 4, 194: 5, 93: 4, 297: 4, 131: 4}, 'aut_a_p2_r6': {105: 3, 194: 4, 93: 2, 297: 2, 131: 3}, 'aut_a_p2_r7': {105: 4, 194: 5, 93: 4, 297: 2, 131: 3}, 'aut_a_p2_r8': {105: 4, 194: 4, 93: 3, 297: 2, 131: 2}, 'aut_a_p2_r9': {105: 3, 194: 5, 93: 3, 297: 2, 131: 5}, 'aut_a_p2_r10': {105: 3, 194: 4, 93: 3, 297: 2, 131: 5}, 'aut_a_p2_r11': {105: 3, 194: 4, 93: 4, 297: 2, 131: 2}, 'aut_a_p2_r12': {105: 4, 194: 5, 93: 4, 297: 3, 131: 2}, 'aut_a_p2_r13': {105: 4, 194: 3, 93: 3, 297: 4, 131: 4}, 'aut_a_p2_r14': {105: 4, 194: 4, 93: 4, 297: 2, 131: 4}, 'aut_a_p2_r15': {105: 4, 194: 4, 93: 5, 297: 4, 131: 5}, 'gpe_a_p1_r1': {105: 5, 194: 5, 93: 3, 297: 2, 131: 5}, 'gpe_a_p1_r2': {105: 4, 194: 4, 93: 3, 297: 2, 131: 4}, 'gpe_a_p1_r3': {105: 2, 194: 1, 93: 3, 297: 4, 131: 1}, 'gpe_a_p1_r4': {105: 4, 194: 5, 93: 3, 297: 2, 131: 3}, 'gpe_a_p1_r5': {105: 5, 194: 5, 93: 5, 297: 4, 131: 4}, 'gpe_a_p1_r6': {105: 4, 194: 5, 93: 5, 297: 2, 131: 3}, 'gpe_a_p1_r7': {105: 3, 194: 4, 93: 3, 297: 2, 131: 2}, 'gpe_a_p1_r8': {105: 3, 194: 4, 93: 4, 297: 2, 131: 4}, 'gpe_a_p1_r9': {105: 4, 194: 5, 93: 5, 297: 3, 131: 5}, 'gpe_a_p1_r10': {105: 3, 194: 3, 93: 4, 297: 1, 131: 1}, 'gpe_a_p1_r11': {105: 3, 194: 4, 93: 3, 297: 3, 131: 2}, 'gpe_a_p1_r12': {105: 3, 194: 4, 93: 4, 297: 2, 131: 5}, 'gpe_a_p1_r13': {105: 3, 194: 4, 93: 3, 297: 2, 131: 3}, 'gpe_a_p1_r14': {105: 3, 194: 2, 93: 2, 297: 5, 131: 1}, 'gpe_a_p1_r15': {105: 4, 194: 5, 93: 3, 297: 1, 131: 3}, 'gpe_a_p2_r1': {105: 3.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'gpe_a_p2_r2': {105: 3.0, 194: 4.0, 93: 2.0, 297: 1.0, 131: 4.0}, 'gpe_a_p2_r3': {105: 3, 194: 4, 93: 2, 297: 1, 131: 'BLANK'}, 'gpe_a_p2_r4': {105: 3.0, 194: 5.0, 93: 4.0, 297: 4.0, 131: 4.0}, 'gpe_a_p2_r5': {105: 4.0, 194: 5.0, 93: 5.0, 297: 5.0, 131: 5.0}, 'gpe_a_p2_r6': {105: 3.0, 194: 4.0, 93: 2.0, 297: 1.0, 131: 3.0}, 'gpe_a_p2_r7': {105: 4.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'gpe_a_p2_r8': {105: 4.0, 194: 5.0, 93: 4.0, 297: 5.0, 131: 4.0}, 'gpe_a_p2_r9': {105: 3.0, 194: 5.0, 93: 2.0, 297: 1.0, 131: 3.0}, 'gpe_a_p2_r10': {105: 4.0, 194: 3.0, 93: 3.0, 297: 4.0, 131: 5.0}, 'gpe_a_p2_r11': {105: 4.0, 194: 4.0, 93: 2.0, 297: 1.0, 131: 2.0}, 'gpe_a_p2_r12': {105: 4, 194: 4, 93: 3, 297: 2, 131: 2}, 'gpe_a_p2_r13': {105: 4.0, 194: 5.0, 93: 4.0, 297: 5.0, 131: 5.0}, 'gpe_a_p2_r14': {105: 4.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'gpe_a_p2_r15': {105: 3.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'tdr_a_p1_r1': {105: 4, 194: 4, 93: 4, 297: 4, 131: 1}, 'tdr_a_p1_r2': {105: 4, 194: 5, 93: 4, 297: 4, 131: 5}, 'tdr_a_p1_r3': {105: 3, 194: 4, 93: 3, 297: 4, 131: 3}, 'tdr_a_p1_r4': {105: 4, 194: 5, 93: 3, 297: 4, 131: 4}, 'tdr_a_p1_r5': {105: 3, 194: 5, 93: 4, 297: 4, 131: 3}, 'tdr_a_p1_r6': {105: 5, 194: 5, 93: 3, 297: 4, 131: 4}, 'tdr_a_p1_r7': {105: 4, 194: 5, 93: 4, 297: 3, 131: 3}, 'tdr_a_p1_r8': {105: 5, 194: 5, 93: 3, 297: 3, 131: 4}, 'tdr_a_p1_r9': {105: 2, 194: 3, 93: 2, 297: 4, 131: 1}, 'tdr_a_p1_r10': {105: 3, 194: 4, 93: 3, 297: 2, 131: 3}, 'tdr_a_p1_r11': {105: 4, 194: 5, 93: 4, 297: 3, 131: 3}, 'tdr_a_p1_r12': {105: 3, 194: 5, 93: 3, 297: 4, 131: 4}, 'tdr_a_p1_r13': {105: 5, 194: 5, 93: 4, 297: 3, 131: 5}, 'tdr_a_p1_r14': {105: 4, 194: 4, 93: 3, 297: 3, 131: 4}, 'tdr_a_p1_r15': {105: 3, 194: 4, 93: 4, 297: 3, 131: 4}, 'tdr_a_p2_r1': {105: 4, 194: 5, 93: 4, 297: 3, 131: 4}, 'tdr_a_p2_r2': {105: 4, 194: 5, 93: 4, 297: 5, 131: 5}, 'tdr_a_p2_r3': {105: 4, 194: 5, 93: 4, 297: 3, 131: 3}, 'tdr_a_p2_r4': {105: 4, 194: 5, 93: 4, 297: 4, 131: 5}, 'tdr_a_p2_r5': {105: 4, 194: 5, 93: 4, 297: 2, 131: 4}, 'tdr_a_p2_r6': {105: 4, 194: 4, 93: 4, 297: 4, 131: 5}, 'tdr_a_p2_r7': {105: 4, 194: 5, 93: 3, 297: 3, 131: 5}, 'tdr_a_p2_r8': {105: 4, 194: 5, 93: 4, 297: -2.4, 131: 4}, 'tdr_a_p2_r9': {105: 4, 194: 3, 93: 3, 297: 2, 131: 5}, 'tdr_a_p2_r10': {105: 3, 194: 4, 93: 3, 297: 3, 131: 4}, 'tdr_a_p2_r11': {105: 3, 194: 4, 93: 3, 297: 4, 131: 5}, 'tdr_a_p2_r12': {105: 4, 194: 4, 93: 4, 297: 4, 131: 5}, 'tdr_a_p2_r13': {105: 4, 194: 4, 93: 4, 297: 4, 131: 5}, 'tdr_a_p2_r14': {105: 4, 194: 5, 93: 4, 297: 4, 131: 4}, 'tdr_a_p2_r15': {105: 4, 194: 5, 93: 4, 297: 4, 131: 5}, 'cso_a_p1_r1': {105: 3.0, 194: 1.0, 93: 2.0, 297: nan, 131: 3.0}, 'cso_a_p1_r2': {105: 3, 194: 4, 93: 3, 297: nan, 131: 2}, 'cso_a_p1_r3': {105: 4.0, 194: 5.0, 93: 5.0, 297: nan, 131: 5.0}, 'cso_a_p1_r4': {105: 4, 194: 5, 93: 2, 297: nan, 131: 4}, 'cso_a_p1_r5': {105: 4.0, 194: 5.0, 93: 4.0, 297: nan, 131: 3.0}, 'cso_a_p1_r6': {105: 4, 194: 4, 93: 4, 297: nan, 131: 4}, 'cso_a_p1_r7': {105: 4, 194: 5, 93: 4, 297: nan, 131: 5}, 'cso_a_p1_r8': {105: 4, 194: 5, 93: 4, 297: nan, 131: 4}, 'cso_a_p1_r9': {105: 4.0, 194: 3.0, 93: 4.0, 297: nan, 131: 5.0}, 'cso_a_p1_r10': {105: 4.0, 194: 5.0, 93: 5.0, 297: nan, 131: 5.0}, 'cso_a_p1_r11': {105: 4.0, 194: 5.0, 93: 4.0, 297: nan, 131: 5.0}, 'cso_a_p1_r12': {105: 4.0, 194: 5.0, 93: 5.0, 297: nan, 131: 4.0}, 'cso_a_p1_r13': {105: 4.0, 194: 2.0, 93: 4.0, 297: nan, 131: 4.0}, 'cso_a_p1_r14': {105: -3.4, 194: 3.0, 93: 2.0, 297: nan, 131: 3.0}, 'cso_a_p1_r15': {105: 4.0, 194: 5.0, 93: 4.0, 297: nan, 131: 5.0}, 'cso_a_p2_r1': {105: 4, 194: 5, 93: 4, 297: 5, 131: 5}, 'cso_a_p2_r2': {105: 4.0, 194: 4.0, 93: 3.0, 297: 5.0, 131: 4.0}, 'cso_a_p2_r3': {105: 4.0, 194: 4.0, 93: 4.0, 297: 4.0, 131: 5.0}, 'cso_a_p2_r4': {105: 3, 194: 5, 93: 4, 297: 4, 131: 4}, 'cso_a_p2_r5': {105: 4.0, 194: 5.0, 93: 4.0, 297: 5.0, 131: 5.0}, 'cso_a_p2_r6': {105: 4.0, 194: 5.0, 93: 4.0, 297: 5.0, 131: 5.0}, 'cso_a_p2_r7': {105: 4, 194: 5, 93: 4, 297: 5, 131: 5}, 'cso_a_p2_r8': {105: 3, 194: 5, 93: 4, 297: 4, 131: 5}, 'cso_a_p2_r9': {105: 4.0, 194: 3.0, 93: 4.0, 297: 5.0, 131: 5.0}, 'cso_a_p2_r10': {105: 4, 194: 2, 93: 4, 297: 3, 131: 5}, 'cso_a_p2_r11': {105: 4.0, 194: 4.0, 93: 4.0, 297: 5.0, 131: 5.0}, 'cso_a_p2_r12': {105: 4.0, 194: 4.0, 93: 4.0, 297: 5.0, 131: 5.0}, 'cso_a_p2_r13': {105: 4, 194: 4, 93: 3, 297: 5, 131: 5}, 'cso_a_p2_r14': {105: 4, 194: 5, 93: -3.4, 297: 5, 131: 4}, 'cso_a_p2_r15': {105: 4.0, 194: 5.0, 93: 4.0, 297: 4.0, 131: 4.0}, 'rin_a_p1_r1': {105: 3.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'rin_a_p1_r2': {105: 3.0, 194: 5.0, 93: 3.0, 297: 2.0, 131: 2.0}, 'rin_a_p1_r3': {105: 3.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 5.0}, 'rin_a_p1_r4': {105: 2, 194: 4, 93: 1, 297: 4, 131: 2}, 'rin_a_p1_r5': {105: 3.0, 194: 5.0, 93: 3.0, 297: 4.0, 131: 2.0}, 'rin_a_p1_r6': {105: 3, 194: 3, 93: 4, 297: 2, 131: 5}, 'rin_a_p1_r7': {105: 3.0, 194: 5.0, 93: 3.0, 297: 4.0, 131: 5.0}, 'rin_a_p1_r8': {105: 3.0, 194: 4.0, 93: 3.0, 297: 4.0, 131: 5.0}, 'rin_a_p1_r9': {105: 3.0, 194: 4.0, 93: 3.0, 297: 4.0, 131: 2.0}, 'rin_a_p1_r10': {105: 3, 194: 5, 93: 4, 297: 3, 131: 5}, 'rin_a_p1_r11': {105: 3, 194: 5, 93: 3, 297: 3, 131: 4}, 'rin_a_p1_r12': {105: 3, 194: 4, 93: 2, 297: 1, 131: 3}, 'rin_a_p1_r13': {105: 3.0, 194: 4.0, 93: 3.0, 297: 5.0, 131: 3.0}, 'rin_a_p1_r14': {105: 3.0, 194: 5.0, 93: 4.0, 297: 4.0, 131: 5.0}, 'rin_a_p1_r15': {105: 3.0, 194: 5.0, 93: 2.0, 297: 4.0, 131: 1.0}, 'rin_a_p2_r1': {105: 4, 194: 5, 93: 5, 297: nan, 131: 5}, 'rin_a_p2_r2': {105: 4, 194: 5, 93: 4, 297: nan, 131: 5}, 'rin_a_p2_r3': {105: 4, 194: 4, 93: 4, 297: nan, 131: 5}, 'rin_a_p2_r4': {105: 4, 194: 2, 93: 4, 297: nan, 131: 4}, 'rin_a_p2_r5': {105: 4, 194: 3, 93: 4, 297: nan, 131: 4}, 'rin_a_p2_r6': {105: 3, 194: 4, 93: 3, 297: nan, 131: 3}, 'rin_a_p2_r7': {105: 3, 194: 4, 93: 3, 297: nan, 131: 5}, 'rin_a_p2_r8': {105: 4, 194: 5, 93: 4, 297: nan, 131: 4}, 'rin_a_p2_r9': {105: 4, 194: 4, 93: 4, 297: nan, 131: 4}, 'rin_a_p2_r10': {105: 4, 194: 5, 93: 4, 297: nan, 131: 3}, 'rin_a_p2_r11': {105: 4, 194: 4, 93: 4, 297: nan, 131: 5}, 'rin_a_p2_r12': {105: 3, 194: 4, 93: 4, 297: nan, 131: 3}, 'rin_a_p2_r13': {105: 4, 194: 5, 93: 4, 297: nan, 131: 5}, 'rin_a_p2_r14': {105: 4, 194: 4, 93: 3, 297: nan, 131: 5}, 'rin_a_p2_r15': {105: 4, 194: 1, 93: 4, 297: nan, 131: 5}, 'pcr_a_p1_r1': {105: 4.0, 194: 5.0, 93: 2.0, 297: 2.0, 131: 3.0}, 'pcr_a_p1_r2': {105: 3.0, 194: 4.0, 93: 4.0, 297: 3.0, 131: 3.0}, 'pcr_a_p1_r3': {105: 4.0, 194: 5.0, 93: 2.0, 297: 3.0, 131: 3.0}, 'pcr_a_p1_r4': {105: 4, 194: 5, 93: 3, 297: 2, 131: 4}, 'pcr_a_p1_r5': {105: 4.0, 194: 5.0, 93: 2.0, 297: 4.0, 131: 5.0}, 'pcr_a_p1_r6': {105: 4, 194: 5, 93: 2, 297: 2, 131: 2}, 'pcr_a_p1_r7': {105: 4, 194: 4, 93: 4, 297: 3, 131: 4}, 'pcr_a_p1_r8': {105: 4, 194: 5, 93: 3, 297: 4, 131: 4}, 'pcr_a_p1_r9': {105: 4, 194: 4, 93: 4, 297: 4, 131: 5}, 'pcr_a_p1_r10': {105: 4, 194: 5, 93: 4, 297: 2, 131: 4}, 'pcr_a_p1_r11': {105: 4.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'pcr_a_p1_r12': {105: 4, 194: 5, 93: 3, 297: 2, 131: 3}, 'pcr_a_p1_r13': {105: 4, 194: 5, 93: 2, 297: 2, 131: 3}, 'pcr_a_p1_r14': {105: 4.0, 194: 4.0, 93: 2.0, 297: 2.0, 131: 3.0}, 'pcr_a_p1_r15': {105: 4.0, 194: 5.0, 93: 3.0, 297: 2.0, 131: 5.0}, 'pcr_a_p2_r1': {105: 5.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 5.0}, 'pcr_a_p2_r2': {105: 4.0, 194: 5.0, 93: 3.0, 297: 2.0, 131: 5.0}, 'pcr_a_p2_r3': {105: 3.0, 194: 5.0, 93: 4.0, 297: 4.0, 131: 4.0}, 'pcr_a_p2_r4': {105: 4, 194: 4, 93: 2, 297: 3, 131: 5}, 'pcr_a_p2_r5': {105: 5.0, 194: 5.0, 93: 5.0, 297: 3.0, 131: 4.0}, 'pcr_a_p2_r6': {105: 3.0, 194: 1.0, 93: 1.0, 297: 1.0, 131: 2.0}, 'pcr_a_p2_r7': {105: 5, 194: 4, 93: 3, 297: 3, 131: 5}, 'pcr_a_p2_r8': {105: 5, 194: 3, 93: 3, 297: 2, 131: 4}, 'pcr_a_p2_r9': {105: 5, 194: 2, 93: 2, 297: 4, 131: 3}, 'pcr_a_p2_r10': {105: 3, 194: 2, 93: 1, 297: 2, 131: 2}, 'pcr_a_p2_r11': {105: 4, 194: 3, 93: 2, 297: 3, 131: 4}, 'pcr_a_p2_r12': {105: 5.0, 194: 4.0, 93: 3.0, 297: 3.0, 131: 5.0}, 'pcr_a_p2_r13': {105: 4, 194: 5, 93: 1, 297: 1, 131: 5}, 'pcr_a_p2_r14': {105: 5.0, 194: 5.0, 93: 3.0, 297: 2.0, 131: 4.0}, 'pcr_a_p2_r15': {105: 2.0, 194: 5.0, 93: 5.0, 297: 2.0, 131: 2.0}, 'det_a_p1_r1': {105: 3.0, 194: 4.0, 93: 4.0, 297: 4.0, 131: 5.0}, 'det_a_p1_r2': {105: 4.0, 194: 4.0, 93: 4.0, 297: 3.0, 131: 4.0}, 'det_a_p1_r3': {105: 4.0, 194: 4.0, 93: 4.0, 297: 3.0, 131: 5.0}, 'det_a_p1_r4': {105: 4.0, 194: 4.0, 93: 4.0, 297: 2.0, 131: 4.0}, 'det_a_p1_r5': {105: 3.0, 194: 1.0, 93: 2.0, 297: 4.0, 131: 1.0}, 'det_a_p1_r6': {105: 3, 194: 5, 93: 4, 297: 2, 131: 5}, 'det_a_p1_r7': {105: 4.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 5.0}, 'det_a_p1_r8': {105: 3, 194: 5, 93: 4, 297: 2, 131: 5}, 'det_a_p1_r9': {105: 3, 194: 1, 93: 2, 297: 3, 131: 1}, 'det_a_p1_r10': {105: 4.0, 194: 1.0, 93: 2.0, 297: 2.0, 131: 1.0}, 'det_a_p1_r11': {105: 4, 194: 4, 93: 3, 297: 2, 131: 5}, 'det_a_p1_r12': {105: 2, 194: 5, 93: 4, 297: 3, 131: 5}, 'det_a_p1_r13': {105: 4.0, 194: 5.0, 93: 4.0, 297: 4.0, 131: 5.0}, 'det_a_p1_r14': {105: 2, 194: 1, 93: 2, 297: 3, 131: 5}, 'det_a_p1_r15': {105: 1.0, 194: 2.0, 93: 3.0, 297: 5.0, 131: 1.0}, 'det_a_p2_r1': {105: 3.0, 194: 5.0, 93: 4.0, 297: 3.0, 131: 3.0}, 'det_a_p2_r2': {105: 2.0, 194: 5.0, 93: 3.0, 297: 4.0, 131: 5.0}, 'det_a_p2_r3': {105: 3.0, 194: 4.0, 93: 2.0, 297: 2.0, 131: 4.0}, 'det_a_p2_r4': {105: 4, 194: 4, 93: 4, 297: 2, 131: 3}, 'det_a_p2_r5': {105: 5, 194: 3, 93: 5, 297: 4, 131: 2}, 'det_a_p2_r6': {105: 3, 194: 4, 93: 3, 297: 3, 131: 4}, 'det_a_p2_r7': {105: 3.0, 194: 2.0, 93: 3.0, 297: 3.0, 131: 1.0}, 'det_a_p2_r8': {105: 3, 194: 4, 93: 4, 297: 2, 131: 5}, 'det_a_p2_r9': {105: 3, 194: 3, 93: 3, 297: 2, 131: 5}, 'det_a_p2_r10': {105: 4, 194: 4, 93: 4, 297: 4, 131: 5}, 'det_a_p2_r11': {105: 3, 194: 2, 93: 3, 297: 2, 131: 5}, 'det_a_p2_r12': {105: 2, 194: 4, 93: 2, 297: 3, 131: 5}, 'det_a_p2_r13': {105: 4, 194: 4, 93: 4, 297: 4, 131: 4}, 'det_a_p2_r14': {105: 4, 194: 4, 93: 4, 297: 4, 131: 4}, 'det_a_p2_r15': {105: 4, 194: 5, 93: 3, 297: 2, 131: 5}, 'lid_a_p1_r1': {105: 3.0, 194: 4.0, 93: 4.0, 297: nan, 131: 4.0}, 'lid_a_p1_r2': {105: 3.0, 194: 4.0, 93: 3.0, 297: nan, 131: 3.0}, 'lid_a_p1_r3': {105: 3, 194: 4, 93: 3, 297: nan, 131: 3}, 'lid_a_p1_r4': {105: 3, 194: 5, 93: 4, 297: nan, 131: 4}, 'lid_a_p1_r5': {105: 4.0, 194: 4.0, 93: 2.0, 297: nan, 131: 4.0}, 'lid_a_p1_r6': {105: 4.0, 194: 5.0, 93: 4.0, 297: nan, 131: 4.0}, 'lid_a_p1_r7': {105: 3.0, 194: 4.0, 93: 4.0, 297: nan, 131: 4.0}, 'lid_a_p1_r8': {105: 1.0, 194: 5.0, 93: 5.0, 297: nan, 131: 5.0}, 'lid_a_p1_r9': {105: -1.5, 194: 5, 93: 5, 297: nan, 131: 3}, 'lid_a_p1_r10': {105: 1, 194: 3, 93: 3, 297: nan, 131: 5}, 'lid_a_p1_r11': {105: 2, 194: 2, 93: 3, 297: nan, 131: 2}, 'lid_a_p1_r12': {105: 1, 194: 1, 93: 3, 297: nan, 131: 1}, 'lid_a_p1_r13': {105: 3, 194: 5, 93: 4, 297: nan, 131: 5}, 'lid_a_p1_r14': {105: 3.0, 194: 4.0, 93: 4.0, 297: nan, 131: 3.0}, 'lid_a_p1_r15': {105: 3, 194: 3, 93: 3, 297: nan, 131: 3}, 'lid_a_p2_r1': {105: 3, 194: 4, 93: 3, 297: 4, 131: 5}, 'lid_a_p2_r2': {105: 3, 194: 4, 93: 3, 297: 3, 131: 4}, 'lid_a_p2_r3': {105: 4, 194: 4, 93: 4, 297: 3, 131: 3}, 'lid_a_p2_r4': {105: 3, 194: 5, 93: 2, 297: 2, 131: 4}, 'lid_a_p2_r5': {105: 5, 194: 5, 93: 3, 297: 2, 131: 3}, 'lid_a_p2_r6': {105: 4, 194: 4, 93: 3, 297: 4, 131: 4}, 'lid_a_p2_r7': {105: 5, 194: 5, 93: 5, 297: 4, 131: 4}, 'lid_a_p2_r8': {105: 2, 194: 3, 93: 3, 297: 2, 131: 5}, 'lid_a_p2_r9': {105: 3, 194: 4, 93: 3, 297: 2, 131: 4}, 'lid_a_p2_r10': {105: 3.0, 194: 5.0, 93: 3.0, 297: 4.0, 131: 5.0}, 'lid_a_p2_r11': {105: 3, 194: 3, 93: 3, 297: 3, 131: 3}, 'lid_a_p2_r12': {105: 2.0, 194: 4.0, 93: 2.0, 297: 2.0, 131: 5.0}, 'lid_a_p2_r13': {105: 5.0, 194: 3.0, 93: 4.0, 297: 3.0, 131: 4.0}, 'lid_a_p2_r14': {105: 3.0, 194: 5.0, 93: 4.0, 297: 2.0, 131: 3.0}, 'lid_a_p2_r15': {105: 4.0, 194: 5.0, 93: 3.0, 297: 2.0, 131: 4.0}}
)

df.loc[:,df.columns.str.contains("_a_")] = df.apply(pd.to_numeric, errors='coerce')
df.loc[:,df.columns.str.contains("_a_")] = df.mask((df < 1) | (df > 5))
df


问:
How to use pcse.base_classes
For the first time, I wanted to use the pcse package. I installed the Requirements and dependencies according to the document and also test the installation of the package, but when I use the following command in the main code:

```<code>from pcse.base_classes import ParameterProvider
</code>```

it gives an error:

No module named 'pcse.base_classes'

答:
I have never used that module but

```<code>from pcse.base import ParameterProvider
</code>```

works for me. Here are the methods it provides:

```<code>>>> dir(ParameterProvider)
['_MutableMapping__marker', '__abstractmethods__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_cropdata', '_iter', '_maps', '_ncrops_activated', '_override', '_sitedata', '_soildata', '_test_uniqueness', '_timerdata', '_unique_parameters', 'clear', 'clear_override', 'get', 'items', 'keys', 'logger', 'next', 'pop', 'popitem', 'set_active_crop', 'set_override', 'setdefault', 'update', 'values']
</code>```

They changed it in 5.4.2-3-g3efc1fd.

Title: How to use pcse.base_classes

Body:
For the first time, I wanted to use the pcse package. I installed the Requirements and dependencies according to the document and also test the installation of the package, but when I use the following command in the main code:

from pcse.base_classes import ParameterProvider

it gives an error:

No module named 'pcse.base_classes'

Body:
I have never used that module but

from pcse.base import ParameterProvider

works for me. Here are the methods it provides:

>>> dir(ParameterProvider)
['_MutableMapping__marker', '__abstractmethods__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_cropdata', '_iter', '_maps', '_ncrops_activated', '_override', '_sitedata', '_soildata', '_test_uniqueness', '_timerdata', '_unique_parameters', 'clear', 'clear_override', 'get', 'items', 'keys', 'logger', 'next', 'pop', 'popitem', 'set_active_crop', 'set_override', 'setdefault', 'update', 'values']

They changed it in 5.4.2-3-g3efc1fd.


问:
Flutter ScreenState Dispose method exception
When I try to navigate away from one screen to another in flutter, I am getting an exception stating that the ScreenState that I am changing away from does not call super.dispose() in its dispose method. However, the overriden dispose method clearly calls super.dispose().

Attached are the relevant class and the logs. Any help would be greatly appreciated.

Class:

```<code>import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:kickit/screens/feed_screen.dart';
import 'package:kickit/screens/profile_screen.dart';
import 'package:kickit/screens/talk_screen.dart';
import 'package:kickit/utils/values/internal_strings.dart';
import 'package:kickit/utils/values/strings.dart';
import 'package:kickit/utils/values/values.dart';

/// Main screen that contains three screens within for displaying information.
/// Contains a:
/// - [TalkScreen]
/// - [FeedScreen]
/// - [ProfileScreen]
class MainScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new _MainScreenState();
  }
}

/// Manages the state of [MainScreen].
class _MainScreenState extends State<MainScreen> with ChangeNotifier {
  // A PageController to manage which screen is currently shown.
  PageController _pageController;

  // The current page that is in focus.
  // - 0 => ConversationScreen
  // - 1 => FeedScreen
  // - 2 => ProfileScreen
  int _page = 1;

  /// Initializes this [MainScreen], setting the initial screen to the
  /// [FeedScreen] due to [_page] starting at 1.
  @override
  void initState() {
    super.initState();
    _pageController = new PageController(
      initialPage: _page,
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      // key: new ValueKey(InternalStrings.mainScaffoldKey),
      appBar: _appBar(),
      body: _mainScreens(),
      bottomNavigationBar: _bottomBar(),
    );
  }

  /// Gets an [AppBar] that will be shown across all of the screens controlled
  /// by this [MainScreen]
  AppBar _appBar() {
    return new AppBar(
      // key: new ValueKey(InternalStrings.mainAppBarKey),
      centerTitle: true,
      title: new Text(
        Strings.title,
        style: Theme.of(context).textTheme.title,
      ),
      actions: <Widget>[
        new IconButton(
          key: new ValueKey(InternalStrings.mainSettingsButtonKey),
          icon: new Icon(Icons.settings),
          onPressed: () => Navigator
              .of(context)
              .pushReplacementNamed(InternalStrings.mainScreenRoute),
        ),
      ],
    );
  }

  /// Gets a [PageView] storing the screens controlled by this [MainScreen].
  PageView _mainScreens() {
    return new PageView(
      // key: new ValueKey(InternalStrings.mainPageViewKey),
      controller: _pageController,
      onPageChanged: _onPageChanged,
      children: <Widget>[
        new Container(
          child: new TalkScreen(),
        ),
        new Container(
          child: new FeedScreen(),
        ),
        new Container(
          child: new ProfileScreen(),
        ),
      ],
    );
  }

  /// Gets a [BottomNavigationBar] that will be shown across all of the screens
  /// controlled by this [MainScreen]
  BottomNavigationBar _bottomBar() {
    return new BottomNavigationBar(
      // key: new ValueKey(InternalStrings.mainBottomBarKey),
      items: [
        new BottomNavigationBarItem(
          icon: new Icon(Icons.people),
          title: new Text(Strings.mainBottomBarTalk),
        ),
        new BottomNavigationBarItem(
          icon: new Icon(Icons.list),
          title: new Text(Strings.mainBottomBarFeed),
        ),
        new BottomNavigationBarItem(
          icon: new Icon(Icons.person),
          title: new Text(Strings.mainBottomBarProfile),
        ),
      ],
      onTap: _onNavigationTap,
      currentIndex: _page,
    );
  }

  /// Handles a tap on the bottom navigation bar.
  void _onNavigationTap(int page) {
    _pageController.animateToPage(
      page,
      duration: Values.animationShort,
      curve: Curves.ease,
    );
  }

  /// Handles a page change and updates the bottom bar.
  void _onPageChanged(int page) {
    this._pageController.notifyListeners();
    setState(() {
      this._page = page;
    });
  }

  /// Dispose of the [PageController] when disposed.
  @override
  void dispose() {
    super.dispose();
    _pageController.dispose();
  }
}
</code>```

Logs:

```<code>I/flutter (18130): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (18130): The following assertion was thrown while finalizing the widget tree:
I/flutter (18130): MainScreenState.dispose failed to call super.dispose.
I/flutter (18130): dispose() implementations must always call their superclass dispose() method, to ensure that all the
I/flutter (18130): resources used by the widget are fully released.
I/flutter (18130):
I/flutter (18130): When the exception was thrown, this was the stack:
I/flutter (18130): #0      StatefulElement.unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:3771)
I/flutter (18130): #1      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:3776)
I/flutter (18130): #2      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1670)
I/flutter (18130): #3      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #4      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #7      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #8      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #9      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #10     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #11     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #12     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #13     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #14     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #15     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #16     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #17     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #18     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #19     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #20     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #21     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #22     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #23     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #24     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #25     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #26     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #27     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #28     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #29     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #30     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #31     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #32     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #33     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #34     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #35     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #36     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #37     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #38     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #39     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #40     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #41     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #42     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #43     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #44     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #45     ListIterable.forEach (dart:_internal/iterable.dart:39)
I/flutter (18130): #46     _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1679)
I/flutter (18130): #47     BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2296)
I/flutter (18130): #48     BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2128)
I/flutter (18130): #49     BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2295)
I/flutter (18130): #50     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:623)
I/flutter (18130): #51     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208)
I/flutter (18130): #52     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990)
I/flutter (18130): #53     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930)
I/flutter (18130): #54     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842)
I/flutter (18130): #55     _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:120)
I/flutter (18130): #56     _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:109)
I/flutter (18130): ════════════════════════════════════════════════════════════════════════════════════════════════════
Application finished.
</code>```

答:
On dispose method you should have your super.dispose() at the end, like this:

```<code>@override
void dispose() {
  _pageController.dispose();
  super.dispose();             <-- Here should be super.dispose()
}
</code>```

And for everyone who has a similar problem using ChangeNotifier and TickerProviderStateMixin the solution is as follows:

```<code>@override
void dispose() {
  _pageController.dispose();
  dispose();              <-- Just add this line before super.dispose()
  super.dispose();
}
</code>```

I hope you find it useful. ✌

Body:
When I try to navigate away from one screen to another in flutter, I am getting an exception stating that the ScreenState that I am changing away from does not call super.dispose() in its dispose method. However, the overriden dispose method clearly calls super.dispose().

Attached are the relevant class and the logs. Any help would be greatly appreciated.

Class:

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:kickit/screens/feed_screen.dart';
import 'package:kickit/screens/profile_screen.dart';
import 'package:kickit/screens/talk_screen.dart';
import 'package:kickit/utils/values/internal_strings.dart';
import 'package:kickit/utils/values/strings.dart';
import 'package:kickit/utils/values/values.dart';

/// Main screen that contains three screens within for displaying information.
/// Contains a:
/// - [TalkScreen]
/// - [FeedScreen]
/// - [ProfileScreen]
class MainScreen extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new _MainScreenState();
  }
}

/// Manages the state of [MainScreen].
class _MainScreenState extends State<MainScreen> with ChangeNotifier {
  // A PageController to manage which screen is currently shown.
  PageController _pageController;

  // The current page that is in focus.
  // - 0 => ConversationScreen
  // - 1 => FeedScreen
  // - 2 => ProfileScreen
  int _page = 1;

  /// Initializes this [MainScreen], setting the initial screen to the
  /// [FeedScreen] due to [_page] starting at 1.
  @override
  void initState() {
    super.initState();
    _pageController = new PageController(
      initialPage: _page,
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      // key: new ValueKey(InternalStrings.mainScaffoldKey),
      appBar: _appBar(),
      body: _mainScreens(),
      bottomNavigationBar: _bottomBar(),
    );
  }

  /// Gets an [AppBar] that will be shown across all of the screens controlled
  /// by this [MainScreen]
  AppBar _appBar() {
    return new AppBar(
      // key: new ValueKey(InternalStrings.mainAppBarKey),
      centerTitle: true,
      title: new Text(
        Strings.title,
        style: Theme.of(context).textTheme.title,
      ),
      actions: <Widget>[
        new IconButton(
          key: new ValueKey(InternalStrings.mainSettingsButtonKey),
          icon: new Icon(Icons.settings),
          onPressed: () => Navigator
              .of(context)
              .pushReplacementNamed(InternalStrings.mainScreenRoute),
        ),
      ],
    );
  }

  /// Gets a [PageView] storing the screens controlled by this [MainScreen].
  PageView _mainScreens() {
    return new PageView(
      // key: new ValueKey(InternalStrings.mainPageViewKey),
      controller: _pageController,
      onPageChanged: _onPageChanged,
      children: <Widget>[
        new Container(
          child: new TalkScreen(),
        ),
        new Container(
          child: new FeedScreen(),
        ),
        new Container(
          child: new ProfileScreen(),
        ),
      ],
    );
  }

  /// Gets a [BottomNavigationBar] that will be shown across all of the screens
  /// controlled by this [MainScreen]
  BottomNavigationBar _bottomBar() {
    return new BottomNavigationBar(
      // key: new ValueKey(InternalStrings.mainBottomBarKey),
      items: [
        new BottomNavigationBarItem(
          icon: new Icon(Icons.people),
          title: new Text(Strings.mainBottomBarTalk),
        ),
        new BottomNavigationBarItem(
          icon: new Icon(Icons.list),
          title: new Text(Strings.mainBottomBarFeed),
        ),
        new BottomNavigationBarItem(
          icon: new Icon(Icons.person),
          title: new Text(Strings.mainBottomBarProfile),
        ),
      ],
      onTap: _onNavigationTap,
      currentIndex: _page,
    );
  }

  /// Handles a tap on the bottom navigation bar.
  void _onNavigationTap(int page) {
    _pageController.animateToPage(
      page,
      duration: Values.animationShort,
      curve: Curves.ease,
    );
  }

  /// Handles a page change and updates the bottom bar.
  void _onPageChanged(int page) {
    this._pageController.notifyListeners();
    setState(() {
      this._page = page;
    });
  }

  /// Dispose of the [PageController] when disposed.
  @override
  void dispose() {
    super.dispose();
    _pageController.dispose();
  }
}

Logs:

I/flutter (18130): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (18130): The following assertion was thrown while finalizing the widget tree:
I/flutter (18130): MainScreenState.dispose failed to call super.dispose.
I/flutter (18130): dispose() implementations must always call their superclass dispose() method, to ensure that all the
I/flutter (18130): resources used by the widget are fully released.
I/flutter (18130):
I/flutter (18130): When the exception was thrown, this was the stack:
I/flutter (18130): #0      StatefulElement.unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:3771)
I/flutter (18130): #1      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:3776)
I/flutter (18130): #2      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1670)
I/flutter (18130): #3      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #4      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #7      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #8      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #9      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #10     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #11     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #12     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #13     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #14     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #15     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #16     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #17     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #18     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #19     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #20     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #21     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #22     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #23     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #24     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #25     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #26     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #27     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #28     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #29     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #30     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #31     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #32     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #33     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #34     SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4584)
I/flutter (18130): #35     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #36     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #37     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #38     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #39     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #40     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #41     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #42     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1668)
I/flutter (18130): #43     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3644)
I/flutter (18130): #44     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1666)
I/flutter (18130): #45     ListIterable.forEach (dart:_internal/iterable.dart:39)
I/flutter (18130): #46     _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1679)
I/flutter (18130): #47     BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2296)
I/flutter (18130): #48     BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2128)
I/flutter (18130): #49     BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2295)
I/flutter (18130): #50     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:623)
I/flutter (18130): #51     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208)
I/flutter (18130): #52     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990)
I/flutter (18130): #53     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930)
I/flutter (18130): #54     BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842)
I/flutter (18130): #55     _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:120)
I/flutter (18130): #56     _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:109)
I/flutter (18130): ════════════════════════════════════════════════════════════════════════════════════════════════════
Application finished.

Body:
On dispose method you should have your super.dispose() at the end, like this:

@override
void dispose() {
  _pageController.dispose();
  super.dispose();             <-- Here should be super.dispose()
}

And for everyone who has a similar problem using ChangeNotifier and TickerProviderStateMixin the solution is as follows:

@override
void dispose() {
  _pageController.dispose();
  dispose();              <-- Just add this line before super.dispose()
  super.dispose();
}

I hope you find it useful. ✌


问:
Envoy as proxy to public internet services
How can I configure Envoy as a proxy to public internet services, such that each path might route to a different service? For example:</p>
```<code>http://foo.example.com/service1/* -> http://somewhere.com/*
http://foo.example.com/service2/* -> http://somewhereelse.com/*
</code>```

答:
Assuming your envoy proxy is accessible at http://foo.example.com, you can use a config like this :

static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 80
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          codec_type: AUTO
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: backend
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/service1"
                route:
                  prefix_rewrite: "/"
                  cluster: service1
                  auto_host_rewrite: true
              - match:
                  prefix: "/service2"
                route:
                  prefix_rewrite: "/"
                  cluster: service2
                  auto_host_rewrite: true
          http_filters:
          - name: envoy.filters.http.router
  clusters:
  - name: service1
    connect_timeout: 15s
    type: LOGICAL_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service1
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: somewhere.com
                port_value: 80
  - name: service2
    connect_timeout: 15s
    type: LOGICAL_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service2
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: somewhereelse.com
                port_value: 80
```

The important parts are :

prefix_rewrite: "/" to rewrite http://foo.example.com/service1/stuff to http://somewhere.com/stuff (in fact, to remove /service1)

auto_host_rewrite: true to add a Host header during forwarding (hostname of the upstream host of the cluster)

Body:
How can I configure Envoy as a proxy to public internet services, such that each path might route to a different service? For example:

http://foo.example.com/service1/* -> http://somewhere.com/*
http://foo.example.com/service2/* -> http://somewhereelse.com/*

Body:
Assuming your envoy proxy is accessible at http://foo.example.com, you can use a config like this :

static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 80
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          codec_type: AUTO
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: backend
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/service1"
                route:
                  prefix_rewrite: "/"
                  cluster: service1
                  auto_host_rewrite: true
              - match:
                  prefix: "/service2"
                route:
                  prefix_rewrite: "/"
                  cluster: service2
                  auto_host_rewrite: true
          http_filters:
          - name: envoy.filters.http.router
  clusters:
  - name: service1
    connect_timeout: 15s
    type: LOGICAL_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service1
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: somewhere.com
                port_value: 80
  - name: service2
    connect_timeout: 15s
    type: LOGICAL_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service2
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: somewhereelse.com
                port_value: 80

The important parts are :

prefix_rewrite: "/" to rewrite http://foo.example.com/service1/stuff to http://somewhere.com/stuff (in fact, to remove /service1)

auto_host_rewrite: true to add a Host header during forwarding (hostname of the upstream host of the cluster)