开发者

Custom extension in rails routes

I have开发者_StackOverflow中文版 to serve rails generated zip files. For example from the following REST route: http://foo.com/controller/show/filename.zip

How i need to map routes.rb to allow the routing of zip files (instead searching for static files in /public) to my controller?


If you've set up your routes using the map.resources in config/routes.rb then I think you already have the routes you want. What I think you need is to add a custom mime type to you controller like this:

Mime::Type.register_alias "application/zip", :zip

Then

respond_to do |format|
  format.zip { ... }
end

Also available in request.format

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜