0

The following code works in development like a charm, but in production no update is ever issued to the database. Basically I am trying to update a collection element that is nested 3 levels deep ..

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 

The model Article in question looks like this:

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

The funny thing here is that even when I run webrick locally in production mode it works like a charm. Only once I deploy to my ubuntu server running mongodb v1.2.2 the above code silently does nothing.

I even went as far as to copy my environments/development.rb onto my environments/production.rb hoping to fix the issue.. but to no avail..

Any ideas? I am running rails 3.2.7 with mongoid 3.0.3

It would also be helpful if someone could point out how to make the moped/mongoid debug log messages show up in production.log. I configured Debugging as described in the logs - but these debug messages are only visible when running rails s - not in production.log

4

1 回答 1

0

自己解决了。。

原来来自官方 Ubuntu 存储库源的 Mongodb 1.2.2 是问题所在。更新到 2.0.5 后一切正常。

于 2012-08-28T07:31:07.063 回答