Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tatsuro-ueda/3444930 to your computer and use it in GitHub Desktop.
Save tatsuro-ueda/3444930 to your computer and use it in GitHub Desktop.
herokuでmongolabを使う時のはまりどころ
# herokuでmongolabを使う時のはまりどころ
# 最初にUTF8宣言
#encoding: utf-8
# ....
Mongoid.configure do |conf|
# db名は決まっているものを使う(最後の2フレーズは同じになる)
conf.master = Mongo::Connection.from_uri('mongodb://heroku_app6978307:[email protected]:37447/heroku_app6978307').db('heroku_app6978307')
end
# 途中で外部から取ってきた文字列などは即UTF8化
xml = Net::HTTP.get(host, path).force_encoding('utf-8')
h = Hash.from_xml(xml)['rss']['channel']['item']
h.each do |key|
rss = RSS.new(:title => key['title'],
:description => key['description'],
:link => key['link'])
puts rss.title
rss.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment