我有map.resources :posts
,我希望能够以降价格式提供邮寄正文。所以我设置了respond_to
块:
respond_to do |format|
format.markdown {
render :text => @post.body.to_s
}
end
但是当我尝试访问/posts/1234.markdown
时,我收到此错误:
NameError (uninitialized constant Mime::MARKDOWN):
app/controllers/posts_controller.rb:96:in `show'
app/controllers/posts_controller.rb:79:in `show'
如何将降价添加为可接受的格式?我在哪里可以看到可接受的格式列表?
答案 0 :(得分:35)
http://weblog.rubyonrails.org/2006/12/19/using-custom-mime-types
# add in config/initializers/mime_types.rb
Mime::Type.register "text/markdown", :markdown
答案 1 :(得分:2)
Mime::Types.register