Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 3.2 store fields #19

Closed
alecslupu opened this issue Feb 16, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@alecslupu
Copy link

commented Feb 16, 2012

I have the following setup using mecached:

class Collection < ActiveRecord::Base
cache_records :key => 'collection'

my methods

end

whenever i try to save or edit a record that i have tried to edit before, I get a stacktrace like this, only if i have the record-cache enabled...

ActionView::Template::Error (no member 'completed_fame' in struct):
1: = form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge((hdv = field.html_default_value).nil? ? {} : { :value => hdv, :checked => hdv })
activerecord (3.2.0) lib/active_record/store.rb:44:in []' activerecord (3.2.0) lib/active_record/store.rb:44:inblock (2 levels) in store_accessor'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/lib/rails_admin/abstract_object.rb:21:in method_missing' actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1154:invalue_before_type_cast'
actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1142:in value_before_type_cast' actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1036:inblock in to_input_field_tag'
actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1036:in fetch' actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1036:into_input_field_tag'
actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1049:in to_number_field_tag' actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:938:innumber_field'
actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:1277:in number_field' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/views/rails_admin/main/_form_field.html.haml:1:in__mnt_data_myapp_shared_bundle_ruby_______bundler_gems_rails_admin____________f_app_views_rails_admin_main__form_field_html_haml__1921039710147814407_47694540'
actionpack (3.2.0) lib/action_view/template.rb:143:in block in render' activesupport (3.2.0) lib/active_support/notifications.rb:125:ininstrument'
actionpack (3.2.0) lib/action_view/template.rb:141:in render' actionpack (3.2.0) lib/action_view/renderer/partial_renderer.rb:257:inrender_partial'
actionpack (3.2.0) lib/action_view/renderer/partial_renderer.rb:230:in block in render' actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in block in instrument' activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument'
actionpack (3.2.0) lib/action_view/renderer/partial_renderer.rb:229:in render' actionpack (3.2.0) lib/action_view/renderer/renderer.rb:41:inrender_partial'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:15:in render' actionpack (3.2.0) lib/action_view/helpers/rendering_helper.rb:24:inrender'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:11:in block in render_with_haml' haml (3.1.4) lib/haml/helpers.rb:90:innon_haml'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:11:in render_with_haml' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/lib/rails_admin/config/fields/base.rb:211:inrender'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/lib/rails_admin/config/proxy.rb:29:in method_missing' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:68:infield_for'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:50:in block in input_for' actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:inblock in capture'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:187:in with_output_buffer' haml (3.1.4) lib/haml/helpers/xss_mods.rb:109:inwith_output_buffer_with_haml_xss'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in capture' haml (3.1.4) lib/haml/helpers/action_view_mods.rb:105:incapture_with_haml'
actionpack (3.2.0) lib/action_view/helpers/tag_helper.rb:91:in content_tag' haml (3.1.4) lib/haml/helpers/action_view_mods.rb:123:incontent_tag_with_haml'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:49:in input_for' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:42:inblock in field_wrapper_for'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in block in capture' actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:187:inwith_output_buffer'
haml (3.1.4) lib/haml/helpers/xss_mods.rb:109:in with_output_buffer_with_haml_xss' actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:incapture'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:105:in capture_with_haml' actionpack (3.2.0) lib/action_view/helpers/tag_helper.rb:91:incontent_tag'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:123:in content_tag_with_haml' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:40:infield_wrapper_for'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:28:in block (2 levels) in fieldset_for' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:28:inmap'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:28:in block in fieldset_for' actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:inblock in capture'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:187:in with_output_buffer' haml (3.1.4) lib/haml/helpers/xss_mods.rb:109:inwith_output_buffer_with_haml_xss'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in capture' haml (3.1.4) lib/haml/helpers/action_view_mods.rb:105:incapture_with_haml'
actionpack (3.2.0) lib/action_view/helpers/tag_helper.rb:91:in content_tag' haml (3.1.4) lib/haml/helpers/action_view_mods.rb:123:incontent_tag_with_haml'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:24:in fieldset_for' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:17:inblock in generate'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:16:in map' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/form_builder.rb:16:ingenerate'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/views/rails_admin/main/edit.html.haml:2:in block in __mnt_data_myapp_shared_bundle_ruby_______bundler_gems_rails_admin____________f_app_views_rails_admin_main_edit_html_haml__2936297698482363203_49865300' haml (3.1.4) lib/haml/helpers/action_view_mods.rb:181:incall'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:181:in block (2 levels) in form_for_with_haml' haml (3.1.4) lib/haml/helpers.rb:255:inwith_tabs'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:181:in block in form_for_with_haml' actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:inblock in capture'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:187:in with_output_buffer' haml (3.1.4) lib/haml/helpers/xss_mods.rb:109:inwith_output_buffer_with_haml_xss'
actionpack (3.2.0) lib/action_view/helpers/capture_helper.rb:40:in capture' haml (3.1.4) lib/haml/helpers/action_view_mods.rb:105:incapture_with_haml'
actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:606:in fields_for' actionpack (3.2.0) lib/action_view/helpers/form_helper.rb:377:inform_for'
haml (3.1.4) lib/haml/helpers/action_view_mods.rb:183:in form_for_with_haml' haml (3.1.4) lib/haml/helpers/xss_mods.rb:132:inform_for_with_haml_xss'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/helpers/rails_admin/main_helper.rb:7:in rails_admin_form_for' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/app/views/rails_admin/main/edit.html.haml:1:in__mnt_data_myapp_shared_bundle_ruby_______bundler_gems_rails_admin____________f_app_views_rails_admin_main_edit_html_haml__2936297698482363203_49865300'
actionpack (3.2.0) lib/action_view/template.rb:143:in block in render' activesupport (3.2.0) lib/active_support/notifications.rb:125:ininstrument'
actionpack (3.2.0) lib/action_view/template.rb:141:in render' actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:41:inblock (2 levels) in render_template'
actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:in block in instrument' activesupport (3.2.0) lib/active_support/notifications.rb:123:inblock in instrument'
activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (3.2.0) lib/active_support/notifications.rb:123:ininstrument'
actionpack (3.2.0) lib/action_view/renderer/abstract_renderer.rb:38:in instrument' actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:40:inblock in render_template'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:48:in render_with_layout' actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:39:inrender_template'
actionpack (3.2.0) lib/action_view/renderer/template_renderer.rb:12:in render' actionpack (3.2.0) lib/action_view/renderer/renderer.rb:36:inrender_template'
actionpack (3.2.0) lib/action_view/renderer/renderer.rb:17:in render' actionpack (3.2.0) lib/abstract_controller/rendering.rb:109:in_render_template'
actionpack (3.2.0) lib/action_controller/metal/streaming.rb:225:in _render_template' actionpack (3.2.0) lib/abstract_controller/rendering.rb:103:inrender_to_body'
actionpack (3.2.0) lib/action_controller/metal/renderers.rb:28:in render_to_body' actionpack (3.2.0) lib/action_controller/metal/compatibility.rb:50:inrender_to_body'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:88:in render' actionpack (3.2.0) lib/action_controller/metal/rendering.rb:16:inrender'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:40:in block (2 levels) in render' activesupport (3.2.0) lib/active_support/core_ext/benchmark.rb:5:inblock in ms'
/usr/lib/ruby/1.9.1/benchmark.rb:309:in realtime' activesupport (3.2.0) lib/active_support/core_ext/benchmark.rb:5:inms'
actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:40:in block in render' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:83:incleanup_view_runtime'
activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:24:in cleanup_view_runtime' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:39:inrender'
remotipart (1.0.2) lib/remotipart/render_overrides.rb:8:in render' /myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/lib/rails_admin/config/actions/edit.rb:21:inblock (4 levels) in class:Edit'
actionpack (3.2.0) lib/action_controller/metal/mime_responds.rb:195:in call' actionpack (3.2.0) lib/action_controller/metal/mime_responds.rb:195:inrespond_to'
/myapp_path//shared/bundle/ruby/1.9.1/bundler/gems/rails_admin-05315224490f/lib/rails_admin/config/actions/edit.rb:20:in block (2 levels) in <class:Edit>' (eval):9:ininstance_eval'
(eval):9:in edit' actionpack (3.2.0) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (3.2.0) lib/abstract_controller/base.rb:167:in process_action' actionpack (3.2.0) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (3.2.0) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (3.2.0) lib/active_support/callbacks.rb:491:in_run__712079326750545375__process_action__810452953766824551__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.0) lib/active_support/callbacks.rb:385:in_run_process_action_callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.0) lib/abstract_controller/callbacks.rb:17:inprocess_action'
actionpack (3.2.0) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in block in instrument' activesupport (3.2.0) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (3.2.0) lib/active_support/notifications.rb:123:in instrument' actionpack (3.2.0) lib/action_controller/metal/instrumentation.rb:29:inprocess_action'
actionpack (3.2.0) lib/action_controller/metal/params_wrapper.rb:205:in process_action' activerecord (3.2.0) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in block in process_action' newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:255:inblock in perform_action_with_newrelic_trace'
newrelic_rpm (3.3.1) lib/new_relic/agent/method_tracer.rb:242:in trace_execution_scoped' newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:250:inperform_action_with_newrelic_trace'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in process_action' actionpack (3.2.0) lib/abstract_controller/base.rb:121:inprocess'
actionpack (3.2.0) lib/abstract_controller/rendering.rb:45:in process' actionpack (3.2.0) lib/action_controller/metal.rb:203:indispatch'
actionpack (3.2.0) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.2.0) lib/action_controller/metal.rb:246:inblock in action'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:in call' actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:66:indispatch'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:30:in call' journey (1.0.1) lib/journey/router.rb:68:inblock in call'
journey (1.0.1) lib/journey/router.rb:56:in each' journey (1.0.1) lib/journey/router.rb:56:incall'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in call' railties (3.2.0) lib/rails/engine.rb:479:incall'
railties (3.2.0) lib/rails/railtie/configurable.rb:30:in method_missing' journey (1.0.1) lib/journey/router.rb:68:inblock in call'
journey (1.0.1) lib/journey/router.rb:56:in each' journey (1.0.1) lib/journey/router.rb:56:incall'
actionpack (3.2.0) lib/action_dispatch/routing/route_set.rb:570:in call' rack-pjax (0.5.7) lib/rack/pjax.rb:12:incall'
omniauth (1.0.2) lib/omniauth/strategy.rb:168:in call!' omniauth (1.0.2) lib/omniauth/strategy.rb:148:incall'
newrelic_rpm (3.3.1) lib/new_relic/rack/browser_monitoring.rb:23:in call' warden (1.1.0) lib/warden/manager.rb:35:inblock in call'
warden (1.1.0) lib/warden/manager.rb:34:in catch' warden (1.1.0) lib/warden/manager.rb:34:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in call' rack (1.4.1) lib/rack/etag.rb:23:incall'
rack (1.4.1) lib/rack/conditionalget.rb:25:in call' actionpack (3.2.0) lib/action_dispatch/middleware/head.rb:14:incall'
remotipart (1.0.2) lib/remotipart/middleware.rb:30:in call' actionpack (3.2.0) lib/action_dispatch/middleware/params_parser.rb:21:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/flash.rb:242:in call' rack (1.4.1) lib/rack/session/abstract/id.rb:205:incontext'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in call' actionpack (3.2.0) lib/action_dispatch/middleware/cookies.rb:338:incall'
activerecord (3.2.0) lib/active_record/query_cache.rb:64:in call' activerecord (3.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:28:in block in call' activesupport (3.2.0) lib/active_support/callbacks.rb:405:in_run__2606656878487081079__call__415961845225187871__callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.0) lib/active_support/callbacks.rb:385:in_run_call_callbacks'
activesupport (3.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (3.2.0) lib/action_dispatch/middleware/callbacks.rb:27:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/remote_ip.rb:31:in call' actionpack (3.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall'
actionpack (3.2.0) lib/action_dispatch/middleware/show_exceptions.rb:56:in call' railties (3.2.0) lib/rails/rack/logger.rb:26:incall_app'
railties (3.2.0) lib/rails/rack/logger.rb:16:in call' actionpack (3.2.0) lib/action_dispatch/middleware/request_id.rb:22:incall'
rack (1.4.1) lib/rack/methodoverride.rb:21:in call' rack (1.4.1) lib/rack/runtime.rb:17:incall'
activesupport (3.2.0) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.4.1) lib/rack/lock.rb:15:incall'
railties (3.2.0) lib/rails/engine.rb:479:in call' railties (3.2.0) lib/rails/application.rb:220:incall'
railties (3.2.0) lib/rails/railtie/configurable.rb:30:in method_missing' unicorn (4.2.0) lib/unicorn/http_server.rb:530:inprocess_client'
unicorn (4.2.0) lib/unicorn/http_server.rb:604:in worker_loop' newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:17:incall'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:17:in block (4 levels) in <top (required)>' unicorn (4.2.0) lib/unicorn/http_server.rb:487:inspawn_missing_workers'
unicorn (4.2.0) lib/unicorn/http_server.rb:137:in start' unicorn (4.2.0) bin/unicorn:121:in<top (required)>'
/myapp_path//shared/bundle/ruby/1.9.1/bin/unicorn:19:in load' /myapp_path//shared/bundle/ruby/1.9.1/bin/unicorn:19:in

'

@alecslupu

This comment has been minimized.

Copy link
Author

commented Feb 17, 2012

Apparently in memcached the cached store field is kept as a TS:=ActiveRecord::AttributeMethods::Serialization::Attribute instance ..
Where can i modify ?

@alecslupu

This comment has been minimized.

Copy link
Author

commented Feb 17, 2012

Doing something like this would fix the bug, however will slow the whole process

def deserialize(serialized)
new_attributes = {}
serialized[ATTRIBUTES_KEY].each do |key, value|
value = value.unserialize if value.is_a?(::ActiveRecord::AttributeMethods::Serialization::Attribute)
new_attributes[key] = value
end
record = serialized[CLASS_KEY].constantize.allocate
record.init_with('attributes' => new_attributes)
record
end

orslumen added a commit that referenced this issue Sep 15, 2014

@orslumen

This comment has been minimized.

Copy link
Owner

commented Sep 15, 2014

Yes, this seems to be an issue when using Rails 3.2+

By using record.class.serialized_attributes I was able to implement this with very limited performance impact on models that do not use serialized attributes.

@orslumen orslumen closed this Sep 15, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.