Skip to content

my_resource.data raises Graphiti::Errors::RecordNotFound in #create action after Graphiti::Resource#build(params) when the table is empty #458

@dima4p

Description

@dima4p

`When the table has no record returns @scope.resolve an empty Array.
In my controller there is

# POST /user_absences
def create
  @user_absence = UserAbsenceResource.build(params)
  authorize @user_absence.data

  if @user_absence.save
    render jsonapi: @user_absence, status: 201
  else
    render jsonapi_errors: @user_absence
  end
end

and I get

 Graphiti::Errors::RecordNotFound:
   Specified Record Not Found

in the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions