Skip to content

Instantly share code, notes, and snippets.

@PyYoshi
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PyYoshi/9890000 to your computer and use it in GitHub Desktop.
Save PyYoshi/9890000 to your computer and use it in GitHub Desktop.

Railsのrenderでmsgpackを使えるようにするやつ

インストール

<Rails.root>/config/initializers/に配置

Gemfileに

gem 'msgpack'

を追加

使い方

render :msgpack => {hoge:1, fuga:2}

以上

Mime::Type.register 'application/x-msgpack', :msgpack
# レンダラにmsgpackを追加
ActionController::Renderers.add :msgpack do |data, options|
send_data data.to_msgpack, :type => 'application/x-msgpack'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment