Allow identifier lookup for scope based find_record implementation

This commit is contained in:
2018-12-17 07:43:51 -05:00
parent d3e176ac55
commit 0b25eefb38
+5 -1
View File
@@ -144,7 +144,11 @@ module Dunlop::Ember::ApiBaseController
def find_record(options = {})
scope = record_scope
scope = scope.includes(*Array.wrap(options[:includes])) if options[:includes]
@record = scope.find(params[:id])
if record_class.include?(HasUuidIdentifier) and HasUuidIdentifier::UUID_MATCH =~ params[:id].to_s
@record = scope.find_by(identifier: params[:id]) or raise ActiveRecord::RecordNotFound # I (Benjamin) don't agree with this (raising) behaviour, but this is the rails standard for raising and rescue
else
@record = scope.find(params[:id])
end
end
def record_params