I use rails to protect access to files that should only be served by some users of the web application. For this, I have a controller method that takes information about the file that 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 clue: if they request a resource from. in this my routing does not know how to handle this. In my routes file, I have:
match 'atb_resources/:guid/:resource' => 'atb_resources#show', :as => :get_atb_resource, :via => :get
but if I try this in my specification:
get 'show', :guid => 'some_guid', :resource => 'blah.txt'
The specification does not work with:
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 it normal:
get 'show', :guid => 'some_guid', :resource => 'blahDOTtxt'
I assume the problem is with my routing, but I do not understand how periods affect routes. Any ideas?
source share