Use record_scope for creation in stead of record_class to preserve record_scope specifics current_user.user_filters in dunlop as example

This commit is contained in:
2018-11-17 21:42:16 -03:00
parent 848e39d6d4
commit d3e176ac55
+2 -1
View File
@@ -37,7 +37,7 @@ module Dunlop::Ember::ApiBaseController
end
def create
@record ||= record_class.new(record_params)
@record ||= record_scope.new(record_params)
create_safeguard @record
return if performed?
if @record.save
@@ -189,6 +189,7 @@ module Dunlop::Ember::ApiBaseController
self.class.predicate_end_matcher ||= Regexp.new("(_#{Ransack.predicates.keys.join('|_')})$")
mapped_query = {}
(params[:q] || {}).each do |key, value|
# not setting the matcher means equality
key = "#{key}_eq" unless %w[s sorts].include?(key) or record_class.try(:ransackable_scopes).try(:include?, key.to_sym) or key =~ self.class.predicate_end_matcher # expect equality when no predicate is given
if key =~ /^type_/
# map type to sti_type