Skip to content

Commit

Permalink
Cleanup: Fix name not found issue
Browse files Browse the repository at this point in the history
It's not clear what the origin of this is.
However, the Sequel gem docs clearly document
that if a record doesn't exist, this will return
`nil` rather than raise an exception.

Original error from logs:

```
NameError (uninitialized constant FindResource::NotFound):
app/controllers/concerns/find_resource.rb:23:in `rescue in resource_exists?'
app/controllers/concerns/find_resource.rb:20:in `resource_exists?'
app/controllers/secrets_controller.rb:119:in `error_info'
app/controllers/secrets_controller.rb:23:in `ensure in create'
app/controllers/secrets_controller.rb:30:in `create'
app/controllers/application_controller.rb:83:in `run_with_transaction'
lib/rack/remove_request_parameters.rb:26:in `call'
lib/rack/default_content_type.rb:78:in `call'
```
  • Loading branch information
micahlee authored and evgenys committed Mar 13, 2023
1 parent 117e0ce commit 100e4bc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions app/controllers/concerns/find_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ def resource
end

def resource_exists?
begin
Resource[resource_id] ? true : false
rescue NotFound
false
end
Resource[resource_id] ? true : false
end

def resource_visible?
Expand Down

0 comments on commit 100e4bc

Please sign in to comment.