Rails

文をMeCabで単語に分解して、json として返す処理を作ったところ、to_json すると、すべての単語が \\ufffd になってしまうという問題が発生した。

MeCabが返す string に str.force_encoding(Encoding::UTF_8) とすると、ちゃんと to_json することができた。以下の処理では文字がすべてつぶれてしまう。。 ruby-1.9.2> m = MeCab::Tagger.new ruby-1.9.2> p m.parse("先週、川崎フロンターレの試合を見に…

Rails 3 / rspec / mongo_mapper -> MongoHQ な設定のためもメモ

今後も使いそうなので、メモしておこう必要な gem は先に gem install でいれておく rails rspec rspec-rails mongo-mapper bson bson-ext > gem update アプリケーション内の各ファイルを以下のように変更Gemfile require 'rubygems' require 'mongo' sourc…

respond_to でデフォルトフォーマットを指定する

format.any を指定するらしい respond_to do |format| format.json { render :json => @user } format.any { render :xml => @user } end http://apidock.com/rails/v3.0.0/ActionController/MimeResponds/respond_to

MongoMapper.connetion.connect_to_master は無くなったので注意

mongoDB | Rails - Getting Started このページにある、以下のコード if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| MongoMapper.connection.connect_to_master if forked end end を config/initializer…

RailsでMongoMapperを使うためのリファレンス

RailsTips | MongoMapper, The Rad Mongo Wrapper RailsTips | MongoMapper 0.8: Goodies Galore MongoDB | Rails 3 - Getting Started 観測所日誌 | Rails 3 + MongoDB のメモ

Rails にnokogiriをインストールに失敗したときの対応

こんな感じのエラーで失敗した Installing nokogiri (1.4.3.1) with native extensions /usr/local/lib/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem nati/usr/bin/ruby1.8 extconf.rb checking for libxml/…

Rspec と Cucumber

slide share から参考資料 http://www.slideshare.net/rahoulb/rspec-user-stories-presentation http://www.slideshare.net/josephwilk/outsidein-development-with-cucumber-and-rspec 実際に使っているプロジェクト http://github.com/fdv/typo/tree/mast…

Rails 3 でGoogle Apps のOpenIDを使う

とりあえず、リンクだけ。 http://d.hatena.ne.jp/bekkou68/20100816/1281886942 http://www.slideshare.net/hassox/warden-introduction http://github.com/rails/open_id_authentication