2012-08-28 19 views
0

以下代碼在開發中像魅力一樣工作,但在生產中沒有更新發布到數據庫。基本上我試圖更新一個嵌套3層深的集合元素..Mongoid代碼在生產中不起作用

def set_collection_value                                           
    @article = Article.find(params[:id])                                        
    @article.highlights.items.find(params[:item_id])                                        
    item.update_attributes(params[:values])                                       

    render :json => item                                            
    end 

有問題的模型文章如下:

class Article 
    include Mongoid::Document 

    embeds_one :highlight, class_name: 'Highlight' 
end 

highlight.rb

class Highlight 
    includes Mongoid::Document 
    embedded_in :article 

    embeds_many :items, class_name: 'HighlightElement' 
end 

highlight_item.rb

class HighlightElement                                            
    include Mongoid::Document                                           

    embedded_in :highlight                                            

    field :title, type: String                                           
    field :teaser, type: String                                          
    field :image, type: String                                           
    field :body, type: String                                           

    attr_accessible :title, :teaser, :image, :body                                      
end 

這裏有趣的是,即使我在生產模式下本地運行webrick,它的作用就像一個魅力。只有當我部署到運行mongodb v1.2.2的我的ubuntu服務器時,上面的代碼默默無聞。

我甚至遠到複製我environments/development.rb到我environments/production.rb希望能解決這個問題..但無濟於事..

任何想法去了?我使用mongoid 3.0.3運行rails 3.2.7

如果有人能指出如何讓moped/mongoid調試日誌消息顯示在production.log中,這也會有所幫助。我配置調試as described in the logs - 但運行軌道■當這些調試消息纔可見 - 解決它不production.log

+0

日誌?我懷疑沒有連接到數據庫。關於只讀頁面,/ article/1(猜測)顯示一篇文章呢? – jcollum

+0

是的..一切工作正常..我甚至可以通過其他方法設置值..只是這一個不工作.. – Tigraine

+0

任何想法如何我可以在生產腳踏車日誌?我已經設置日誌記錄調試,如下所述:http://mongoid.org/en/mongoid/docs/installation.html#logging,但他們不顯示在production.log – Tigraine

回答

0

自己..

從Ubuntu官方倉庫源原來的MongoDB 1.2.2是問題。 更新至2.0.5後,所有工作都正常。