开发者

How do I initialize ActionDispatch::ParamsParser in Rails 3.1?

My application defines a custom Mime type for its Rest interface. So I register it in the mime_types.rb initializer:

Mime::Type.register "application/vnd.example.app-v1+xml", :xml_v1

and Rails correctly handles the respond_to blocks in the controllers.

However, I still need to tell Rails that inc开发者_运维知识库oming requests should be parsed as an XML, using ActionDispatch::ParamsParser. I just don't know how to use it inside an initializer. What's the correct way?


This works well:

Mime::Type.register "application/vnd.example.app-v1+xml", :xml_v1

MyRailsApp::Application.config.middleware.delete "ActionDispatch::ParamsParser"
MyRailsApp::Application.config.middleware.use ActionDispatch::ParamsParser, { Mime::XML_V1 => :xml_simple }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜