Geoffrey Roguelon
2013-Feb-01 08:19 UTC
Add a customer renderer but I get missing template
Hi, I''m trying to include the support of Msgpack<https://github.com/msgpack/msgpack-ruby> in Rails 3.2 but when I try to return a mpac response, I get an error concerning a missing template. My renderer: Mime::Type.register ''application/x-mpac'', :mpac ActionController::Renderers.add :mpac do |mpac, options| self.content_type ||= Mime::MPAC self.response_body = mpac.respond_to?(:to_msgpack) ? mpac.to_msgpack : mpac end My controller: class UsersController < ApplicationController respond_to :mpac, :json def show respond_with({ hello: ''world'' }) end end And my serializer: require ''msgpack'' module ActiveModel module Serializers module MPAC extend ActiveSupport::Concern include ActiveModel::Serialization included do extend ActiveModel::Naming end def to_mpac(options = nil) serializable_hash(options).to_msgpack end alias_method :to_msgpack, :to_mpac def from_mpac(msg) MessagePack.unpack(msg) end end end end Anyone has an idea ? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/AzWrkB1iXosJ. For more options, visit https://groups.google.com/groups/opt_out.