def retrieve_resources(action)
      pass unless involved?
      no_route if disabled? action

      model = model_name.constantize
      nested = nested_resources if nested?

      if model.nil? || nested.nil? && nested?
        raise ActiveRecord::RecordNotFound
      else
        resource = nested? ? nested : model

        # Check access to the resource
        method = "limit_#{action}_for".to_sym
        resource = self.class.send(method, resource, current_user) if self.class.respond_to?(method) && !current_user.nil?

        # ONE resource else COLLECTION
        one_id = nested? ? params[:captures].fourth : params[:captures].second if params[:captures].length == 4
        resource = resource.find one_id unless one_id.nil?
        yield(resource).to_json
      end
    rescue ActiveRecord::RecordNotFound
      record_not_found.to_json
    end
def retrieve_resources(action)
      pass unless involved?
      no_route if disabled? action

      model = model_name.constantize
      nested = nested_resources if nested?

      if model.nil? || nested.nil? && nested?
        raise ActiveRecord::RecordNotFound
      else
        resource = nested? ? nested : model

        # Check access to the resource
        method = "limit_#{action}_for".to_sym
        resource = self.class.send(method, resource, current_user) if self.class.respond_to?(method) && !current_user.nil?

        # ONE resource else COLLECTION
        one_id = nested? ? params[:captures].fourth : params[:captures].second if params[:captures].length == 4
        resource = resource.find one_id unless one_id.nil?
        yield(resource).to_json
      end
    rescue ActiveRecord::RecordNotFound
      record_not_found.to_json
    end
Defines a nested route or not and retrieves the correct resource (or resources)
 @param disables is the name to check if it was disabled
 @param &block to be yield with the retrieved resource
 @returns resource in json format