Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
404 if the Repo can't find a document
Browse files Browse the repository at this point in the history
With the introduction of a Repo for fetching documents, the Repo would
throw an error if params[:section_id] didn't match a placeholder file
instead of allowing the controller to respond with a 404. This commit
checks for the existence of a file first, which if false allows the
controller to respond with a 404.
  • Loading branch information
tommyp committed Jun 11, 2014
1 parent 413405c commit 465ef06
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/repositories/manuals_repository.rb
Expand Up @@ -16,7 +16,9 @@ def fetch_from_file(manual_id, section_id)
section_id ||= 'index'
path = "public/#{manual_id}/#{section_id}.json"

build_ostruct(JSON.parse(File.open(path).read))
if File.exists?(path)
build_ostruct(JSON.parse(File.open(path).read))
end
end

def fetch_from_api(manual_id, section_id)
Expand Down

0 comments on commit 465ef06

Please sign in to comment.