Rails 3.2.10 dump format error for symbol(0x46) -
i getting following error:
dump format error symbol(0x46)
in rails application after having implemented following method:
in model:
def common_friends(user) (self.following & user.following).count end def top_5_by_shared_friends following.sort_by{|user| common_friends(user)}.reverse.first(5) end
and in view:
<%= render :partial => 'users/user_profile_summary', :collection => @shared_friends, :as => :user %>
in controller:
@shared_friends = @current_user.top_5_by_shared_friends
now error when render partial in view. i.e. if remove "render partial" line application loads fine, except of course doesn't show content to.
see below application stack trace:
activerecord (3.2.11) lib/active_record/session_store.rb:60:in `load' activerecord (3.2.11) lib/active_record/session_store.rb:60:in `unmarshal' activerecord (3.2.11) lib/active_record/session_store.rb:137:in `data' activerecord (3.2.11) lib/active_record/session_store.rb:315:in `block in get_session' activesupport (3.2.11) lib/active_support/benchmarkable.rb:50:in `silence' activerecord (3.2.11) lib/active_record/session_store.rb:307:in `get_session' rack (1.4.5) lib/rack/session/abstract/id.rb:251:in `load_session' actionpack (3.2.11) lib/action_dispatch/middleware/session/abstract_store.rb:49:in `block in load_session' actionpack (3.2.11) lib/action_dispatch/middleware/session/abstract_store.rb:57:in `stale_session_check!' actionpack (3.2.11) lib/action_dispatch/middleware/session/abstract_store.rb:49:in `load_session' rack (1.4.5) lib/rack/session/abstract/id.rb:135:in `load!' rack (1.4.5) lib/rack/session/abstract/id.rb:127:in `load_for_read!' rack (1.4.5) lib/rack/session/abstract/id.rb:64:in `has_key?' actionpack (3.2.11) lib/action_dispatch/middleware/flash.rb:258:in `ensure in call' actionpack (3.2.11) lib/action_dispatch/middleware/flash.rb:259:in `call' rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context' rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/cookies.rb:341:in `call' activerecord (3.2.11) lib/active_record/query_cache.rb:64:in `call' activerecord (3.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `_run__1662995712724838230__call__2192866322429324249__callbacks' activesupport (3.2.11) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.11) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' activesupport (3.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/reloader.rb:65:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' railties (3.2.11) lib/rails/rack/logger.rb:32:in `call_app' railties (3.2.11) lib/rails/rack/logger.rb:18:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/request_id.rb:22:in `call' rack (1.4.5) lib/rack/methodoverride.rb:21:in `call' rack (1.4.5) lib/rack/runtime.rb:17:in `call' activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:in `call' rack (1.4.5) lib/rack/lock.rb:15:in `call' actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:in `call' railties (3.2.11) lib/rails/engine.rb:479:in `call' railties (3.2.11) lib/rails/application.rb:223:in `call' railties (3.2.11) lib/rails/railtie/configurable.rb:30:in `method_missing' unicorn (4.6.2) lib/unicorn/http_server.rb:552:in `process_client' unicorn (4.6.2) lib/unicorn/http_server.rb:632:in `worker_loop' unicorn (4.6.2) lib/unicorn/http_server.rb:500:in `spawn_missing_workers' unicorn (4.6.2) lib/unicorn/http_server.rb:142:in `start' unicorn (4.6.2) bin/unicorn_rails:209:in `<top (required)>' /home/lgorse/.rvm/gems/ruby-1.9.3-p327/bin/unicorn_rails:19:in `load' /home/lgorse/.rvm/gems/ruby-1.9.3-p327/bin/unicorn_rails:19:in `<main>' /home/lgorse/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval' /home/lgorse/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
i've identified cause of error:
in 1 part of partial, call on:
<li class = "follower_count"><%= pluralize(user.followers.count, "follower") %></li>
simply placing user.followers.count yields error. conflicting model methods don't understand why @ all.
here relationship model - followers relies on :reverse_relationship , think error occurs there i'm not sure why happens here rather other parts of program call followers:
has_many :relationships, :foreign_key => "follower_id", :dependent => :destroy has_many :reverse_relationships, :foreign_key => "followed_id", :dependent => :destroy, :class_name => "relationship" has_many :following, :through => :relationships, :source => :followed has_many :followers, :through => :reverse_relationships, :source => :follower
well figured out hack site working. here is:
in controller, replaced:
@shared_friends = @current_user.top_5_by_shared_friends
with:
@shared_friends = user.find(session['user_id']).top_5_by_shared_friends
this means app has tap database 1 more time, redundant since based on session['user_id'] in before_filter. reason passes correctly , app runs properly.
if has real solution, rather hack this, please chime in.
otherwise accept own answer - given others may solve same problem same hack.
Comments
Post a Comment