title: inserting array data in mongodb using rails
body: <p>I am not able to insert data in mongodb using rails if the data type is of array type</p>
  
  <p>following is the code</p>
  
  <pre><code>def friend
  
  Twitter.configure do |config|
  config.consumer_key = 'GpCZ3ppx2tvOYB7mP4FONw'
  config.consumer_secret = 'ectbzaP2oLPTSMGJaR5Fj6mmdgFyVsWeM9HoZ2iwaI'
  config.oauth_token ='1378905500-TMtwUpl4bVpVDAcZQ29SVONITmFLL1aCzSLHDQQ'
  config.oauth_token_secret = 'SIsfYHqSKfTEUD4dutaI7zYbfJQjxXmiNXiv4vWkfY'
  end
  @frend= Twitter.friends("shamshul2007")
  @frend.each do |hell|
  puts hell.name.inspect.to_s
  end
  
  #=====
  fr=Array.new
  @frend.each do |f|
  
  fr.push(f)
  end
  
  
  #data insertion
  
  @fri=Friend.new
  @fri.username="shamshul2007"
  @fri.friend=fr  
  @fri.save
  end
  </code></pre>
  
  <p>model is friend.rb </p>
  
  <pre><code>class Friend
  include Mongoid::Document
  field :username, type: String
  field :friend, type: Array
  end
  </code></pre>
  
  <p>I got the following error while pushing data to mongodb</p>
  
  <pre><code>undefined method `__bson_dump__' for #&lt;Twitter::User:0x007fbbec1a8538&gt;
  </code></pre>