Allow identifier lookup for scope based find_record implementation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user