app/controllers/api/resources_controller/base.rb in rails-add_ons-1.4.1 vs app/controllers/api/resources_controller/base.rb in rails-add_ons-1.5.0
- old
+ new
@@ -117,10 +117,14 @@
scope = scope.offset(condition.to_i)
when 'order'
scope = scope.order(condition)
when 'includes'
scope = scope.includes(condition.map(&:to_sym))
+ when 'scopes'
+ condition.each do |scope_name|
+ scope = scope.send(scope_name.to_sym)
+ end
else
condition_statement = ::Api::ResourcesController::ConditionParser.new(scope, field, condition).condition_statement
scope = scope.where(condition_statement)
end
end
@@ -151,12 +155,10 @@
module Serialization
private
def serialize_collection(collection)
collection.collect do |resource|
- json = resource.as_json
- json[:errors] = serialize_errors(resource.errors) if resource.errors.any?
- json
+ serialize_resource(resource)
end
end
def serialize_resource(resource)
json = resource.as_json