2013-05-09 20 views
1

我收到以下錯誤轉儲格式錯誤:的Rails 3.2.10符號(0×46)

模型

dump format error for symbol(0x46) 
在我的軌道

已實施以下方法應用後

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 

在我看來:

<%= render :partial => 'users/user_profile_summary', :collection => @shared_friends, :as => :user %> 

在我的控制器:

@shared_friends = @current_user.top_5_by_shared_friends 

現在我只當我渲染部分在我看來,這個錯誤信息。即如果我刪除了「呈現部分」行,應用程序就會正常加載,除非它不顯示我想要的內容。

看到應用程序堆棧跟蹤如下:

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>' 

我已經確定了錯誤的原因:

在我的部分的一個部分

,我呼籲:

<li class = "follower_count"><%= pluralize(user.followers.count, "follower") %></li> 

只需放置user.followers.count就會產生錯誤。這顯然與我的模型方法相沖突,但我不明白爲什麼。

這裏是關係模型 - 追隨者依賴於:reverse_relationship,我認爲有錯誤發生,但我不知道爲什麼會發生在這裏只而不是節目裏我也呼籲追隨者的其他部分:

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 

回答

0

嗯,我想出了一個破解網站的工作。那就是:

在我的控制,我代替:

@shared_friends = @current_user.top_5_by_shared_friends 

有:

@shared_friends = User.find(session['user_id']).top_5_by_shared_friends 

這意味着應用必須挖掘到數據庫中的一個更多的時間,這是多餘的,因爲它已經基於before_filter中的會話['user_id']來做到這一點。但由於某些原因,這通過正確,應用程序運行正常。

如果任何人有一個真正的解決方案,而不是像這樣的黑客攻擊,請附和

否則我會接受我自己的答案 - 給其他人可能有相同的劈解決同樣的問題。

0

只需運行rake tmp:clear即可解決問題。

請參閱here