lib/kojac/kojac_rails.rb in kojac-0.12.0 vs lib/kojac/kojac_rails.rb in kojac-0.13.0
- old
+ new
@@ -303,13 +303,13 @@
raise "#{ma.macro} association unsupported in CREATE"
end
result_key = op[:result_key] || new_sub_item.kojac_key
merge_model_into_results(new_sub_item)
else # create operation on a resource eg. {verb: "CREATE", key: "order_items"} but may have embedded association values
+ raise "User does not have permission for #{op[:verb]} operation on #{model_class.to_s}" unless model_class.ring_can?(:create,ring)
policy = Kojac.policy!(kojac_current_user,model_class)
p_fields = policy.permitted_fields(:write)
- raise "User does not have permission for #{op[:verb]} operation on #{model_class.to_s}" unless model_class.ring_can?(:create,ring)
p_fields = op[:value].permit( *p_fields )
model_class.write_op_filter(current_user,p_fields,op[:value]) if model_class.respond_to? :write_op_filter
item = model_class.create!(p_fields)
@@ -394,10 +394,12 @@
end
else # collection
result_key = op[:result_key] || op[:key]
results[result_key] = []
if scope
- items = scope.load_by_key(key,op)
+ items = scope
+ items = send(:after_scope,items,op) if respond_to? :after_scope
+ items = items.load_by_key(key,op)
#items = scope.by_key(key,op)
#items = items.all
items.each do |item|
item.prepare(key,op) if item.respond_to? :prepare
end
\ No newline at end of file