简体   繁体   中英

How to route to a path/file in Rails?

I have a subdomain that need to point to a folder inside the public folder.

I would be searching for something like this:

constraints DomainConstraint.new(CONFIG[:short_domain]) do
  match '/:id' => '/path/to/folder/with/files/:id'
end

There is any build in way? Or a gem?

I'd use the routing as-is and use send_file , but there may well be a cleaner way that doesn't involve writing an (admittedly trivial) action. (Or handle it at a higher level, depending on what server you're using, I suppose.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM