开发者

route in rails to point to an image in the database

I'm using a paperclip plugin with an extension to write to the database. The default looks like: /screenshots/photos/24?style=thumb which gets caught already by the default routing in routes.rb.

I want to set it to :url =>':relative_root/:class/:attachment/:id/:style/:basename.:extension' (This produces URLs that开发者_JAVA技巧 I like on the page)

But I don't know what to put in routes.rb to get it to hook up correctly...


Can you explicitly declare the route? It would be something like:


  map.connect "screenshots/photos/:id", :controller => "image_controller", :action => "show"

Make sure the route is high enough in route.rd. Then in your image_controller define your show method to load the image.

The priority is based upon order of creation: first created -> highest priority.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜