lib/jsonapi/resource.rb
# Override this on a resource to return a different result code. Any
# value other than :completed will result in operations returning
# `:accepted`
#
# For example to return `:accepted` if your model does not immediately
# save resources to the database you could override `_save` as follows:
#
# ```
# def _save
#   super
#   return :accepted
# end
# ```
Override this on a resource to return a different result code. Any
value other than :completed will result in operations returning
`:accepted`

For example to return `:accepted` if your model does not immediately
save resources to the database you could override `_save` as follows.


Override this on a resource to return a different result code . Any value other than : completed will result in operations returning ` : accepted ` For example to return ` : accepted ` if your model does not immediately save resources to the database you could override ` _save ` as follows .
def _save
      unless @model.valid?
        fail JSONAPI::Exceptions::ValidationErrors.new(self)
      end
      if defined? @model.save
        saved = @model.save(validate: false)
        unless saved
          if @model.errors.present?
            fail JSONAPI::Exceptions::ValidationErrors.new(self)
          else
            fail JSONAPI::Exceptions::SaveFailed.new
          end
        end
      else
        saved = true
      end
      @save_needed = !saved
      :completed
    end
def _save unless @model . valid? fail JSONAPI :: Exceptions :: ValidationErrors . new ( self ) end if defined? @model . save saved = @model . save ( validate : false ) unless saved if @model . errors . present? fail JSONAPI :: Exceptions :: ValidationErrors . new ( self ) else fail JSONAPI :: Exceptions :: SaveFailed . new end end else saved = true end @save_needed = ! saved :completed end
Override this on a resource to return a different result code.
Override this on a resource to return a different result code .