I am using rails to guard access to files that need to be served only to some users of a web app. To do this I have a controller method that accepts information about the file they want to access, checks their authorization, and then if they are authorized uses x-sendfile to send it to them. The concept works fine except for one snag: if they request a resource with a . in it my routing doesn't know to handle it. In my routes file i have:
match 'atb_resources/:guid/:resource' => 'atb_resources#show', :as => :get_atb_resource, :via => :get
and but then if I try this in my spec:
get 'show', :guid => 'some_guid', :resource => 'blah.txt'
the spec fails with a:
Failure/Error: get 'show', :guid => @atb.guid, :resource => 'blah.txt'
ActionController::RoutingError:
No route matches {:guid=>"ABCDEFG5", :resource=>"blah.txt", :controller=>"atb_resources", :action=>"show"}
but this is fine:
get 'show', :guid => 'some_guid', :resource => 'blahDOTtxt'
I am assuming the problem is with my routing, but I don't really understand how periods affect routes. Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…