Created
August 24, 2012 02:40
-
-
Save tatsuro-ueda/3444930 to your computer and use it in GitHub Desktop.
herokuでmongolabを使う時のはまりどころ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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